例: SQL> connect system/manager SQL> Create user user50 identified by user50; SQL> grant connect, resource to user50; 查询用户拥有哪里权限: SQL> select * from dba_role_privs; SQL> select * from dba_sys_privs; SQL> select * from role_sys_privs;
删除用户:
1
SQL> drop user 用户名 cascade; //加上cascade则将用户连同其创建的东西全部删除
3、系统权限传递:
增加WITH ADMIN OPTION选项,则得到的权限可以传递.
1
SQL> grant connect, resorce to user50 with admin option; //可以传递所获权限.
select, update, insert, alter, index, delete, all //all包括所有权限
execute //执行存储过程权限 user01: SQL> grant select, update, insert on product to user02; SQL> grant all on product to user02; user02: SQL> select * from user01.product; // 此时user02查user_tables,不包括user01.product这个表,但如果查all_tables则可以查到,因为他可以访问.
2、 将表的操作权限授予全体用户:
1 2 3 4 5 6
SQL> grant all on product to public; // public表示是所有的用户,这里的all权限不包括drop. [实体权限数据字典]: SQL> select owner, table_name from all_tables; // 用户可以查询的表 SQL> select table_name from user_tables; // 用户创建的表 SQL> select grantor, table_schema, table_name, privilege from all_tab_privs; // 获权可以存取的表(被授权的) SQL> select grantee, owner, table_name, privilege from user_tab_privs; // 授出权限的表(授出的权限)
3、 DBA用户可以操作全体用户的任意基表(无需授权,包括删除):
1 2 3 4 5 6 7 8
DBA用户: SQL> Create table stud02.product( id number(10), name varchar2(20)); SQL> drop table stud02.emp; SQL> create table stud02.employee as select * from scott.emp;
4、实体权限传递(with grant option):
1 2
user01: SQL> grant select, update on product to user02 with grant option; // user02得到权限,并可以传递.
5、实体权限回收:
1 2
user01: SQL>Revoke select, update on product from user02; //传递的权限将全部丢失.
说明 如果取消某个用户的对象权限,那么对于这个用户使用WITH GRANT OPTION授予权限的用户来说,同样还会取消这些用户的相同权限,也就是说取消授权时级联的.