創建用戶并賦予該用戶授權權限。
create user ken identified by ken;
授予權限并附帶admin option
grant create session, create table to ken with admin option;
授予權限,不帶with admin option
grant create view to ken;
新建tom用戶
create user tom identified by tom;
使用ken用戶登錄后對tom授權, 語句執行成功
grant create session, create table to tom; Grant succeeded. 對tom授權,語句執行失敗 grant create view to tom; grant create view to tom * ERROR at line 1: ORA-01031: insufficient privileges
note 注意,回收權限不是級聯的。
從ken回收登錄權限
revoke create session from ken;
此時tom依然可以登錄,但Ken無法登錄了
ERROR: ORA-01045: user KEN lacks CREATE SESSION privilege; logon denied
select distinct privilege from dba_tab_privs;
select grantor, owner, table_name, privilege from dba_tab_privs where grantee = 'TOM';
grant select on t to tom
grant all on emp to monkey;
grant update on emp(sal) to monkey
grant execute on dbms_transaction to ken;
grant index on scott.emp to blake;
revoke select on emp from blake
note 回收Object Privilege 會導致級聯回收。
角色Role,定義一組權限。
select * from role_sys_privs where role='角色名'
select * from role_sys_privs where role='CONNECT';
select * from role_sys_privs where role='RESOURCE';
dba角色具有所有的系統權限,及with admin option選項,默認的dba用戶為sys和system,它們可以將任何系統權限授予其他用戶。但是要注意的是dba角色不具備sysdba和sysoper的特權(啟動和關閉數據庫)
note 一般而言,創建用戶后,給與connect角色和resource就夠了。
create role 角色名 not identified;
建立角色(數據庫驗證)
create role 角色名 identified by 密碼;
grant create session to 角色名 with admin option grant select on scott.emp to 角色名; grant insert, update, delete on scott.emp to 角色名;
grant 角色名 to blake with admin option;
select * from dba_roles;
select privilege, admin_option from role_sys_privs where role='角色名';
select granted_role, default_role from dba_role_privs where grantee = '用戶名';
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。