ORACLE - 用戶和角色的權限管理

在ORACLE中,建立用戶後須要受權才能使用。數據庫

1、用戶管理session

1. 用戶和角色信息查詢ide

--查詢全部用戶
SQL> select * from dba_users;

--經授予的用戶或角色的系統權限
select * from dba_sys_privs;

--數據對象上的全部權限
SQL>select * from dba_tab_privs;

--查看當前用戶的權限和角色
SQL>select * from user_sys_privs;
SQL>select * from role_sys_privs;

--查詢本身把權限授予給其餘用戶狀況
SQL> select * from user_tab_privs;

2. 受權、鎖定與解鎖、密碼更變、用戶刪除、權限回收等spa

grant  create session to name//建立session
grant create table to name//建立表
grant create view to name//建立視圖
grant unlimited tablespace to name//無表空間使用限制
grant  dba to name//管理員受權

--用戶鎖定/解鎖
alter user username account lock/unlock;code

--更變用戶密碼
alter user username identified by yourpassword;對象

--刪除用戶,同時刪除用戶下面的全部表
drop user scott cascade;blog

--權限回收ci

revoke create table from scott cascade constraints;資源

3. 用戶資源配置(CPU/MEMORY等資源分配)it

建立用戶時,沒有指定資源配置,則自動設置爲default。

下面示例密碼資源並分配給用戶:

SQL>create profile pro_name_xx limit password_reuse_max 30 password_reuse_time 100/unlimited;
SQL>alter user scott profile  pro_name_xx;
SQL>alter user scott profile  DEFAULT;
SQL>drop profile pwd_profile;

限制用戶嘗試登錄失敗次數的資源:

SQL> create profile limit_login_failure limit failed_login_attempts 3;

 

 

2、角色管理


下面是數據庫幾種角色擁有的權限關係,能夠用select * from dba_roles查看全部角色 :

名稱

腳本

 

connect

SQL.BSQ

ALTER SESSION

create cluster/database link/sequence/session/synonym/table/view

resource

SQL.BSQ

create cluster/indextype/operator/producedure/sequence/table/tigger/type

dba

SQL.BSQ

全部管理權限

exp_full_database

CATEXP.SQL

導出權限:

Select any table

Backup any table

Execute any producedure

Execute any type

…….

imp_full_database

CATEXP.SQL

全部導入權限

......

與角色相關的表以下:

DBA_COL_PRIVS 數據庫列上的全部權限
DBA_ROLE_PRIVS 顯示已經授予用戶或其餘角色的角色
DBA_TAB_PRIVS 數據庫對象上的全部權限
DBA_SYS_PRIVS 已經授予用戶或角色的系統權限

 

1. 角色的建立、受權、修改與刪除

用戶可自定義角色,而後授予上面的一個或者幾個權限

SQL>create roke xxx identified by xxx;  -- 能夠爲角色設置密碼,更改和刪除角色須要時須要輸入密碼才能執行。
注:角色名與用戶名是在同一個域中,不能重名。
SQL
>grant create session to role_xxx; -- 將建立會話權限授予角色role_xxx
SQL
>grant role_name to user_name; -- 將角色分配給用戶
SQL> revoke roke_r from scott;  -- 回收角色

  SQL>alter roke xxx not identified;

  SQL>alter user user_xxx default role roke_xxx;

  SQL> alter user user_xxx default role all expect role_xxx;

SQL>drop role role_name;
相關文章
相關標籤/搜索