25、用户和权限

--创建用户

create user test identified bytest123;


--把连接权限授予用户

grant connect to test;



--删除用户

drop user test;



--修改用户

alter user test default tablespace users;

alter user test identified bytest111;

alter user test account lock;

alter user test account unlock;

grant resource to test;



--对象授权

grant select on scott.dept to test;

grant execute on scott.proc_test to test;


--级联授权 

--对象授权的级联授权用  with grant option

--级联授权后test用户也有授权给其他用户select on scott.dept 的权限

grant select on scott.dept to test with grant option;

grant insert on scott.dept to test with grant option;

grant all on scott.dept to test with grant option;



--系统授权

grant create table  to test;

grant create user to test;

grant drop user to test;


--级联授权

--系统的级联授权用  with admin option

grant create user to test with admin option;




--通过角色控制权限

create role myrole;

grant select on scott.dept to myrole;

grant select on scott.emp to myrole;

grant myrole to test;




--一般开发用到的权限

grant connect to test;

grant resource to test;



--如果要查询其他用户的表,使用下面语句

grant select any table to test;




--解除对象授权

revoke select on scott.dept from test;

revoke select any table from test;



--解除系统授权

revoke create user  from test;



--解除角色授权

revoke myrole from test;


示例

周所周知,grant是给别的用户赋权限。他不只能够给表,视图赋权限,而且对存储过程,方法,以及包都可以,具体语法参考如下:

    1.grant给表赋权限:

    grant  select/update on  table to user;

    grant  权限 on 表  to 用户。

    2.grant 给存储过程赋权限:

    grant execute on package/function/procedure to user;

    grant execute on 过程、包、方法 to user

    还可以一次给所有的过程赋权限:

    grant execute any procedure to user;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容