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;

你可能感兴趣的:(25、用户和权限)