Oracle用戶、許可權、角色管理1

Oracle用戶、許可權、角色管理

Oracle 許可權設置
一、許可權分類:
系統許可權:系統規定用戶使用資料庫的許可權。(系統許可權是對用戶而言)

實體許可權:某種許可權用戶對其它用戶的表或視圖的存取許可權。(是針對錶或視圖而言的)。

二、系統許可權管理:
1
、系統許可權分類:
DBA: 
擁有全部特權,是系統最高許可權,只有DBA才可以創建資料庫結構。

RESOURCE:擁有Resource許可權的用戶只可以創建實體,不可以創建資料庫結構。

CONNECT:擁有Connect許可權的用戶只可以登錄Oracle,不可以創建實體,不可以創建資料庫結構。

對於普通用戶:授予connect, resource許可權。
對於DBA管理用戶:授予connectresource, dba許可權。

2、系統許可權授權命令:
[
系統許可權只能由DBA用戶授出:sys, system(最開始只能是這兩個用戶)]
授權命令:SQL> grant connect, resource, dba to 用戶名1 [,用戶名2]…;

[普通用戶通過授權可以具有與system相同的用戶許可權,但永遠不能達到與sys用戶相同的許可權,system用戶的許可權也可以被回收。]

例:
SQL> connect system/manager
SQL> Create user user50 identified by user50;
SQL> grant connect, resource to user50;

查詢用戶擁有哪裡許可權:
SQL> select * from dba_role_privs;
SQL> select * from dba_sys_privs;
SQL> select * from role_sys_privs;

刪除用戶:SQL> drop user 用戶名 cascade;  //加上cascade則將用戶連同其創建的東西全部刪除

3、系統許可權傳遞:
增加WITH ADMIN OPTION選項,則得到的許可權可以傳遞。

SQL> grant connect, resorce to user50 with admin option;  //可以傳遞所獲許可權。

4、系統許可權回收:系統許可權只能由DBA用戶回收
命令:SQL> Revoke connect, resource from user50;

說明:

1)如果使用WITH ADMIN OPTION為某個用戶授予系統許可權,那麼對於被這個用戶授予相同許可權的所有用戶來說,取消該用戶的系統許可權並不會級聯取消這些用戶的相同許可權。

2)系統許可權無級聯,即A授予B許可權,B授予C許可權,如果A收回B的許可權,C的許可權不受影響;系統許可權可以跨用戶回收,即A可以直接收回C用戶的許可權。

三、實體許可權管理
1
、實體許可權分類:select, update, insert, alter, index, delete, all  //all包括所有許可權

execute  //
執行存儲過程許可權

user01:
SQL> grant select, update, insert on product to user02;
SQL> grant all on product to user02;

user02:
SQL> select * from user01.product;

// 此時user02user_tables,不包括user01.product這個表,但如果查all_tables則可以查到,因為他可以訪問。


2. 
將表的操作許可權授予全體用戶:
SQL> grant all on product to public;  // public
表示是所有的用戶,這裡的all許可權不包括drop

[實體許可權數據字典]:
SQL> select owner, table_name from all_tables; // 
用戶可以查詢的表
SQL> select table_name from user_tables;  // 
用戶創建的表
SQL> select grantor, table_schema, table_name, privilege from all_tab_privs; // 
獲權可以存取的表(被授權的)
SQL> select grantee, owner, table_name, privilege from user_tab_privs;   // 
授出許可權的表(授出的許可權)

3. DBA用戶可以操作全體用戶的任意基表(無需授權,包括刪除)
DBA
用戶:
SQL> Create table stud02.product(
id number(10),
name varchar2(20));
SQL> drop table stud02.emp;

SQL> create table stud02.employee
as
select * from scott.emp;

4. 實體許可權傳遞(with grant option)
user01:

SQL> grant select, update on product to user02 with grant option; // user02得到許可權,並可以傳遞。

5. 實體許可權回收:
user01:
SQL>Revoke select, update on product from user02;  //
傳遞的許可權將全部丟失。

說明

1)如果取消某個用戶的對象許可權,那麼對於這個用戶使用WITH GRANT OPTION授予許可權的用戶來說,同樣還會取消這些用戶的相同許可權,也就是說取消授權時級聯的。

Oracle 用戶管理
一、創建用戶的Profile文件
SQL> create profile student limit  // student
為資源文件名
FAILED_LOGIN_ATTEMPTS  3  //
指定鎖定用戶的登錄失敗次數
PASSWORD_LOCK_TIME 5  //
指定用戶被鎖定天數
PASSWORD_LIFE_TIME 30  //
指定口令可用天數

二、創建用戶
SQL> Create User username
Identified by password
Default Tablespace tablespace

以下文章點擊率最高

Loading…

     

如果這文章對你有幫助,請掃左上角微信支付-支付寶,給於打賞,以助博客運營