所以也应该赋予相应的权限
SQL>grant unlimited tablespace to test;
这个时候用户就拥有了创建表的权限 由于表是用户test的 相应的他就拥有了对创建的表的增删查改的权限了
3、查看用户拥有什么权限可以通过查询一个系统的视图(数字字典)
SQL>select * from user_sys_privs;
这样就可以知道当前用户的权限
4、撤销权限
SQL> revoke create table from test;
-----------------------------
一些常用视图的区分
dba_tables dba_all_tables user_tables user_all_tables all_tables all_all_tables
当前用户所属的所有表(注意大写)
SQL> select tablespace_name,table_name from user_all_tables where table_name='STUDENT';
SQL> select table_name,tablespace_name from user_tables where table_name='STUDENT';
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
STUDENT USERS
sys 要查看dba_all_tables,ALL_ALL_TABLES才能查看到 test 用户的表。
SQL> select owner,table_name,tablespace_name from dba_all_tables where owner='TEST';
SQL> select owner,table_name,tablespace_name from all_all_tables where owner='TEST';
SQL> select owner,table_name,tablespace_name from dba_tables where owner='TEST';
SQL> select owner,table_name,tablespace_name from ALL_tables where owner='TEST';
OWNER TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
TEST STUDENT USERS
1.DBA_ALL_TABLES describes all object tables and relational tables in the database. Its columns are the same as those in ALL_ALL_TABLES.
2.ALL_ALL_TABLES describes the object tables and relational tables accessible to the current user.
3.USER_ALL_TABLES describes the object tables and relational tables owned by the current user. Its columns (except for OWNER) are the same as those in
ALL_ALL_TABLES.
----------------------------------------------------------------------
情景一:
用户test 用户test1
test1的用户创建了个表mytab 并且插入了一些数据
那么 test用户是否可以访问到test1的mytab怎么访问?
答:不可以,必须先授权
test1必须授权给test :grant select on mytab to test;
那么这个时候test可以通过 select * from test1.mytab;来访问mytab中的数据
如果想把某个表(对象)的所有权限都赋予给test那么可以:
grant all on mytab to test;
撤销所有权限
revoke all on mytab to test;
总结
对于系统权限由sys来做
对于对象权限由 谁拥有谁授权
系统权限
grant create session to test;
grant create table to test;
grant unlimited tablespace to test;
revoke create session from test;
revoke create table from test;
revoke unlimited tablespase from test;
grant create session to public; //表示把创建表的权限赋予所有人
select * from user_sys_privs; //返回当前用户的所有系统权限
对象权限
grant select on mytab to test;
grant all on mytab to test;
revoke select on mytab from test;
revoke all on mytab from test;
select * from user_tab_privs; //返回当前用户所有的对象权限
对象权限可以控制到列
grant update(name) on mytab to test;
grant insert(id) on mytab to test;
select * from user_col_privs;
注意、:查询和删除不能控制到列
需要有commit的 insert update insert
权限的传递
系统权限的传递:
grant alter table to A with admin option;
那么A可以通过把该权限传递给B,如果想B也可以传递下去那么可以也带上with admin option
grant alter table to B;
对象权限的传递:
grant select on mytab to A with grant option;
那么A可以把在表mytab的select权限赋予给B,如果B想也能传递该select权限也可以带上with grant option
grant select on mytab to B;
登陆EM 的用户必须有一下权限
创建了一个用户testem,并有如下授权
create user testem identified by testem;
grant create session,select any dictionary to testem; // testem可以登陆EM,但是还不是em的管理员。
grant MGMT_USER to testem;