權限允許用戶訪問屬於其它用戶的對象或執行程序,
ORACLE系統提供權限:Object 對象級、System 系統級
查看權限的數據字典:
字典名 含義
ROLE_SYS_PRIVS System privileges granted to roles
ROLE_TAB_PRIVS Table privileges granted to roles
USER_ROLE_PRIVS Roles accessible by the user
USER_TAB_PRIVS_MADE Object privileges granted on the user's objects
USER_TAB_PRIVS_RECD Object privileges granted to the user
USER_COL_PRIVS_MADE Object privileges granted on the columns of the user's objects
USER_COL_PRIVS_RECD Object privileges granted to the user on specific columns
1.系統權限(系統權限是對用戶而言):
DBA擁有最高的系統權限:
1,可以創建用戶
語法:create user username identified by password;
例如:create user briup identified by briup;
當用戶創建成功之后,此用戶什么權限都沒有,甚至不能登錄數據庫。
2. 賦予權限:
一個用戶應該具有的基本權限包含:
CREATE SESSION
CREATE TABLE
CREATE SEQUENCE
CREATE VIEW
CREATE PROCEDURE
如果有多個用戶他們都具有相同的權限(create session,create table,create sequence),賦予權限的動作過於麻煩,要給每個用戶分別制定這些權限,因此oracle提出角色的概念,可以將權限賦值給角色,然后再將角色賦值給用戶。
例如,我們當初在進行操作時寫的:
grant resource,connect to briup;
此時resource,connect就是角色。
查詢resource,connect 具有哪些權限可以使用:
select privilege,role
from role_sys_privs
where role = 'CONNECT' or role ='RESOURCE';
語法:
grant xxxx to user_name ;
例如:
grant create view to briup;
3.回收權限
語法:revoke xxx from user_name;
例如:
revoke create view from briup;
4.修改密碼:
語法:alter user xxx identified by xxxx;
例如:
alert user briup identified by briup;
5.刪除用戶:
語法:drop user username [cascade];
note: cascade:當用戶下有表的時候,必須使用cascade級聯刪除。
例如: drop user test cascade;
2.對象權限(針對對象,類似表對象等):
對象權限:select, update, insert, alter, index, delete, all //all包括所有權限
對象的 擁有者擁有所有的權限。
1.給用戶賦予操作對象的權限:
GRANT object_priv [(columns)]
ON object
TO {user|role|PUBLIC}
[WITH GRANT OPTION]; //允許分配到權限的用戶繼續將權限分配給其它用戶
例如:
grant select on s_emp to jd1613;
給jd1613用戶賦予在s_emp表上進行查詢的權利。
grant update(id) on s_emp to jd1613;
給jd1613賦予能夠更新s_emp表上id列的權限。
2.回收權限:同系統權限。
語法:revoke xxx on obj from user;
note: 通過with grant option賦予額權限也會被回收。
例如:
revoke select , update on s_emp from jd1613;
3.創建同義詞: 相當於給對象起別名
語法:create[public] synonym sy_name for obje_name;
note:只有dba才有權利創建public的同義詞
例如:
create synonym emp for s_emp;
4.刪除同義詞:
語法: drop synonym syn_name;
例如:
drop synonym emp;
5.導出數據庫
exp,imp不屬於sqlplus的命令,所以不是在sqlplus終端執行的。
系統終端:exp userid=briup/briup full=y file=briup.dmp
導入:imp userid=briup/briup full=y file=briup.dmp;