Oracle 系統權限、對象權限、角色權限

1.系統權限:系統規定用戶使用數據庫的權限(對用戶而言)
容許用戶執行特定的數據庫動做:如建立表、建立索引、鏈接實例等
查看全部系統權限:SELECT * FROM SYSTEM_PRIVILEGE_MAP
給用戶授予系統權限:grant 系統權限 to 用戶
例:grant connec,resource to scott;
撤消系統權限:revoke 系統權限 from 用戶;
  例:revoke resource from scott;


2.對象權限:某種權限用戶對其它用戶的表或視圖的存取權限(針對表或視圖而言)
容許用戶操做一些特定的對象,如讀取視圖、可更新某些列、執行存儲過程等
給用戶授予對象權限:grant 對象權限 on 對象  to 用戶
例:grant select,update,insert on product to scott;
grant all on product to scott1;
grant all on product to public;  //public表示是全部的用戶
撤消對象權限:revoke 對象權限 on 對象 from 用戶
例:revoke select,update on product from scott;

3.角色權限:角色就是一組權限,更加方便對權限進行管理
建立角色/刪除角色
create role 角色名  /  drop role 角色名
給角色受權
系統權限:grant 系統權限 to 角色名
對象權限:grant 對象權限 on 對象 to 角色名
撤消角色權限: revoke 系統權限 from 角色    ||    revoke 對象權限 on 對象 from 角色

select * from user_sys_privs

查看用戶全部系統權限數據庫

select * from user_role_privs;
查看用戶所屬角色
select * from role_sys_privs;
角色有哪些系統權限
select * from role_tab_privs;

角色有哪些對象權限app

案例:接下來經過一個案例來表達用戶與角色,角色與權限之間的關係,spa


//建立了兩個角色 
create role role_nb; 
create role role_sb;   

//爲role_nb角色賦予權限 
grant create any index to role_nb; 
grant create any snapshot to role_nb; 
grant create any trigger to role_nb; 

//爲role_sb賦予權限 
grant create any procedure to role_sb; 
grant create any sequence to role_sb; 
grant create any snappshot to role_sb; 
grant create any synonym to role_sb; 
grant create any table to role_sb; 
grant create any trigger to role_sb; 

//將role_nb角色賦予給用戶 
grant role_nb to admin; 
grant role_nb to guest; 

//將role_sb角色賦予給用戶 
grant role_sb to admin; 
grant role_sb to hello; 
grant role_sb to loveu;
對象