溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

4、Ora_Sec_創(chuàng)建和管理角色

發(fā)布時(shí)間:2020-07-24 18:23:06 來源:網(wǎng)絡(luò) 閱讀:424 作者:PengChonggui 欄目:數(shù)據(jù)庫

創(chuàng)建和管理角色

角色是一組系統(tǒng)權(quán)限或?qū)ο髾?quán)限,可以作為一個(gè)單元來授予或撤銷,可以在會(huì)話中臨時(shí)激活或禁用已經(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個(gè)預(yù)定義角色,每個(gè)DBA必須熟悉一下角色:

  1. CONNECT   (連接) --用于向后兼容,在11g中僅有CREATE SESSION權(quán)限。

  2. RESOURCE 也是用于向后兼容,此角色可以創(chuàng)建數(shù)據(jù)庫對(duì)象(如表)和過程對(duì)象(如pl/sql過程)。該角色還包括UNLIMITED     TABLESPACE權(quán)限。

  3. DBA 擁有大多數(shù)系統(tǒng)權(quán)限,以及多個(gè)對(duì)象權(quán)限和角色,任何被授予DBA權(quán)限的用戶幾乎可以管理數(shù)據(jù)庫的所有方面(啟動(dòng)和關(guān)閉除外)。

  4. SELECT_CATALOG_ROLE     擁有針對(duì)數(shù)據(jù)字典對(duì)象的2000多個(gè)對(duì)象權(quán)限,但沒有系統(tǒng)權(quán)限或針對(duì)用戶的權(quán)限。這對(duì)新管理員有用,這些人必須監(jiān)視數(shù)據(jù)庫并報(bào)告數(shù)據(jù)庫情況,但看不到用戶數(shù)據(jù)。

  5. SCHEDUALER_ADMIN  擁有用于管理調(diào)度服務(wù)的調(diào)度程序作業(yè)所需的系統(tǒng)權(quán)限。

  6. PUBLIC  此角色始終授予每個(gè)數(shù)據(jù)庫用戶賬戶。如果將某個(gè)權(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;    --更改默認(rèn)行為

--當(dāng)peenboo登錄時(shí),將不啟用任何角色

 

SQL>grantconnect to peenboo;

SQL>alteruser peenboo default role connect;

SQL>select* from dba_role_privs where grantee= 'PEENBOO';

 

在應(yīng)用程序中,可以嵌入軟件命令來啟用 HR_JUNIOR 角色。在會(huì)話中啟用此角色的基本命令為:

SET  ROLE  rolename;

 

為了安全考慮,可以使用以下語法創(chuàng)建角色:

CREATEROLE  rolename  IDENTIFIED USING  procedure_name;

--只能在運(yùn)行 procedure_name 命名的PL/SQL過程來啟用此角色。此過程可以執(zhí)行任意多次的檢查。



向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI