十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
創(chuàng)建和管理角色
站在用戶的角度思考問題,與客戶深入溝通,找到通化網(wǎng)站設(shè)計與通化網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都做網(wǎng)站、成都網(wǎng)站設(shè)計、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名注冊、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務(wù)覆蓋通化地區(qū)。
角色是一組系統(tǒng)權(quán)限或?qū)ο髾?quán)限,可以作為一個單元來授予或撤銷,可以在會話中臨時激活或禁用已經(jīng)授予的權(quán)限。
1、創(chuàng)建角色并授予權(quán)限
CREATEROLE rolename;
案例:
SQL>createrole hr_junior;
SQL>grantcreate session to hr_junior;
SQL>grant select on hr.regions to hr_junior;
SQL>grantselect on hr.locations to hr_junior;
SQL>grantselect on hr.countries to hr_junior;
SQL>grantselect on hr.job_history to hr_junior;
SQL>grantselect on hr.departments to hr_junior;
SQL>grantselect on hr.jobs to hr_junior;
SQL>grantselect on hr.employees to hr_junior;
SQL>createrole hr_senior;
SQL>granthr_junior to hr_senior with admin option;
SQL>grantinsert, update, delete on hr.employees to hr_senior;
SQL>grantinsert, update, delete on hr.job_history to hr_senior;
SQL>createrole hr_manager;
SQL>granthr_senior to hr_manager with admin option;
SQL>grantall on hr.regions to hr_manager;
SQL>grantall on hr.locations to hr_manager;
SQL>grantall on hr.countries to hr_manager;
SQL>grantall on hr.departments to hr_manager;
SQL>grantall on hr.job_history to hr_manager;
SQL>grantall on hr.jobs to hr_manager;
SQL>grantall on hr.employees to hr_manager;
SQL>granthr_manager to scott;
SQL>granthr_junior to peenboo;
2、預(yù)定義的角色
在Oracle數(shù)據(jù)庫中,至少有50個預(yù)定義角色,每個DBA必須熟悉一下角色:
CONNECT (連接)--用于向后兼容,在11g中僅有CREATE SESSION權(quán)限。
RESOURCE也是用于向后兼容,此角色可以創(chuàng)建數(shù)據(jù)庫對象(如表)和過程對象(如pl/sql過程)。該角色還包括UNLIMITED TABLESPACE權(quán)限。
DBA擁有大多數(shù)系統(tǒng)權(quán)限,以及多個對象權(quán)限和角色,任何被授予DBA權(quán)限的用戶幾乎可以管理數(shù)據(jù)庫的所有方面(啟動和關(guān)閉除外)。
SELECT_CATALOG_ROLE 擁有針對數(shù)據(jù)字典對象的2000多個對象權(quán)限,但沒有系統(tǒng)權(quán)限或針對用戶的權(quán)限。這對新管理員有用,這些人必須監(jiān)視數(shù)據(jù)庫并報告數(shù)據(jù)庫情況,但看不到用戶數(shù)據(jù)。
SCHEDUALER_ADMIN 擁有用于管理調(diào)度服務(wù)的調(diào)度程序作業(yè)所需的系統(tǒng)權(quán)限。
PUBLIC 此角色始終授予每個數(shù)據(jù)庫用戶賬戶。如果將某個權(quán)限授予PUBLIC,則該權(quán)限授予所有用戶。
SQL>GRANT select onhr.regions to public; --所有用戶有權(quán)查詢hr.regions
3、啟用角色
SQL>select* from dba_role_privs where grantee = 'PEENBOO';
--查看已為PEENBOO授予了什么角色
SQL>alter user peenboo default role none; --更改默認行為
--當(dāng)peenboo登錄時,將不啟用任何角色
SQL>grantconnect to peenboo;
SQL>alteruser peenboo default role connect;
SQL>select* from dba_role_privs where grantee= 'PEENBOO';
在應(yīng)用程序中,可以嵌入軟件命令來啟用 HR_JUNIOR角色。在會話中啟用此角色的基本命令為:
SET ROLE rolename;
為了安全考慮,可以使用以下語法創(chuàng)建角色:
CREATEROLE rolename IDENTIFIED USING procedure_name;
--只能在運行 procedure_name命名的PL/SQL過程來啟用此角色。此過程可以執(zhí)行任意多次的檢查。