溫馨提示×

溫馨提示×

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

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

Oracle 權(quán)限常用語句【轉(zhuǎn)】

發(fā)布時間:2020-08-12 00:27:59 來源:ITPUB博客 閱讀:147 作者:牛平 欄目:關(guān)系型數(shù)據(jù)庫
http://www.cnblogs.com/ningvsban/p/3606239.html body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', 'HelveticaNeue-Light', 'Ubuntu', 'Droid Sans', sans-serif; font-size: 14px; line-height: 1.6; }

Oracle用戶權(quán)限常用語句

常用的System Privileges

  • create session 連接數(shù)據(jù)庫
  • create table 建表
  • create view 建視圖
  • create public synonym 建同義詞
  • create procedure 建過程、函數(shù)、包
  • create trigger 建觸發(fā)器
  • create cluster 建簇

實(shí)例

創(chuàng)建用戶并賦予該用戶授權(quán)權(quán)限。

create user ken identified by ken;

授予權(quán)限并附帶admin option

grant create session, create table to ken with admin option;

授予權(quán)限,不帶with admin option

grant create view to ken;

新建tom用戶

create user tom identified by tom;

使用ken用戶登錄后對tom授權(quán), 語句執(zhí)行成功

grant create session, create table to tom; Grant succeeded. 對tom授權(quán),語句執(zhí)行失敗 grant create view to tom; grant create view to tom * ERROR at line 1: ORA-01031: insufficient privileges

回收權(quán)限

note 注意,回收權(quán)限不是級聯(lián)的。

從ken回收登錄權(quán)限

revoke create session from ken;

此時tom依然可以登錄,但Ken無法登錄了

ERROR: ORA-01045: user KEN lacks CREATE SESSION privilege; logon denied

常用的Object Privilege

  • alter
  • delete
  • select
  • insert
  • update
  • index
  • references
  • execute
查看系統(tǒng)中的Object Privilege

select distinct privilege from dba_tab_privs;

查看某用戶具有的Object Privilege

select grantor, owner, table_name, privilege from dba_tab_privs where grantee = 'TOM';

授予人可以是該對象所有者或者sys和system用戶。

grant select on t to tom

授予所有權(quán)限

grant all on emp to monkey;

授予列權(quán)限

grant update on emp(sal) to monkey

授予對于某個包的執(zhí)行權(quán)限

grant execute on dbms_transaction to ken;

在別的schema中建立索引,必須具備以下權(quán)限

grant index on scott.emp to blake;

回收對象權(quán)限

revoke select on emp from blake

note 回收Object Privilege 會導(dǎo)致級聯(lián)回收。

角色

角色Role,定義一組權(quán)限。

查詢角色具備的權(quán)限

select * from role_sys_privs where role='角色名'

select * from role_sys_privs where role='CONNECT';

select * from role_sys_privs where role='RESOURCE';

DBA角色

dba角色具有所有的系統(tǒng)權(quán)限,及with admin option選項(xiàng),默認(rèn)的dba用戶為sys和system,它們可以將任何系統(tǒng)權(quán)限授予其他用戶。但是要注意的是dba角色不具備sysdba和sysoper的特權(quán)(啟動和關(guān)閉數(shù)據(jù)庫)

note 一般而言,創(chuàng)建用戶后,給與connect角色和resource就夠了。

自定義角色

建立角色(不驗(yàn)證)

create role 角色名 not identified;

建立角色(數(shù)據(jù)庫驗(yàn)證)

create role 角色名 identified by 密碼;

角色授權(quán)

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 = '用戶名';

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

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

AI