Oracle許可權管理

2021-09-01 21:09:12 字數 4204 閱讀 9161

oracle中的許可權管理

說明:oracle中許可權分為系統許可權和物件許可權

1.oracle中有3個預設的使用者

1.sys使用者 change_on_install dba使用者 (登入是必須加 as sysdba)

2.system使用者 manager 管理員使用者

3.scott使用者 tiger 普通使用者

4.建立新的使用者

create user myuser identified by mypwd;

2.oracle中3個重要的系統許可權

1.oracle連線資料庫許可權

新建立的使用者(myuser)是不能連線資料庫的,需要管理員給他賦予連線資料庫的許可權

grant create session to myuser;

授權成功以後就可以連線資料庫了。

2.oracle中對錶的許可權

grant create table to myuser;(只能給自己建立表,當給自己建立表以後,就相當於對自己的表擁有修改和刪除的許可權)

grant create any table to myuser;(可以給任何人建立表)

grant alter any table to myuser;

grant drop any table to myuser;

沒有alter table 和 drop table 許可權。

授權成功以後就可以建立表。

此時,當前使用者就可以擁有自己的表,然後他可以對自己的表擁有增刪改查許可權,不用再授權。

3.oracle中不受上限的表空間使用許可權

grant unlimited tablespace;

4.撤銷各種許可權

revoke create session from myuser;

revoke create table from myuser;

revoke create any table from myuser;

revoke alter any table from myuser;

revoke drop any table from myuser;

revoke unlimited tablespace from myuser;

5.將系統許可權授予所有人

grant create session to public;

grant create table to public;

grant create any table to public;

grant drop any table to public;

grant alter any table to public;

grant unlimited tablespace to public;

6.檢視當前使用者擁有哪些系統許可權

select * from user_sys_privs;

從檢視中檢視使用者的系統許可權。

3.oracle中物件許可權

1.授予物件許可權

grant select on mytable to otheruser;

grant select any table to otheruser;

grant update on mytable to otheruser;

grant update any table to otheruser;

grant insert on mytable to otheruser;

grant insert any table to otheruser;

grant delete on mytable to otheruser;

grant delete any table to otheruser;

grant all on mytable to otheruser;

grant all on mytable to public;

2.撤銷物件許可權

revoke select on mytable from otheruser;

revoke select any table from otheruser;

revoke update on mytable form otheruser;

revoke update any table from otheruser;

revoke insert on mytable form otheruser;

revoke insert any table from otheruser;

revoke delete on mytable fomr otheruser;

revoke delete any table from otheruser;

revoke all on mytable from otheruser;

revoke all on mytable from public;

3.物件許可權可以控制到列(除了查詢和刪除)

grant update(colname) on mytable to otheruser;

grant insert(colname) on mytable to otheruser;

當然也可以收回列的控制許可權。

4.檢視當前使用者擁有哪些物件許可權

select * from user_tab_privs;

從檢視中檢視使用者的物件許可權

select * from user_col_privs;

從檢視中檢視使用者對列的控制許可權

4.ddl\dml\dcl介紹

1.ddl.資料定義語言

例如:建立表(create),修改表(alter),刪除表等語句(drop)。

2.dml.資料操作語言

例如:插入資料(insert),刪除資料(delete,truncate),更新資料(update),查詢資料語句(select)。

3.dcl.資料控制語言

例如:授權(grant)和撤銷許可權(revoke)等語句。

注意:只有dml需要commit,當然查詢語句不需要commit。

5.oracle中許可權的傳遞

1.對於系統許可權

不允許許可權傳遞

grant create session to myuser;

允許許可權傳遞

grant create session to myuser with admin option;

2.對於物件許可權

不允許許可權傳遞

grant select on mytable to otheruser;

允許許可權傳遞

grant select on mytable to otheruser with grant option;

6.oracle中的角色管理

1.建立角色

create role myrole;

2.給角色授權

grant create session to myrole;

grant create table to myrole;

3.給使用者指定角色

grant myrole to myuser;

4.刪除角色

drop role myrole;

5.有些許可權很高,不能通過角色分配給使用者,只能直接分配給使用者

比如:unlimited tablespace

grant unlimited tablespace to myuser;

7.oracle中的3中驗證機制

1.作業系統驗證

sysdba,sysoper兩個角色的使用者(比如sys使用者)都是用作業系統和密碼檔案驗證

用作業系統驗證時,可以不需要使用者名稱和密碼

2.密碼檔案驗證

當作業系統使用者不存在時,就會進行密碼檔案驗證,就需要正確的使用者名稱密碼。

3.資料庫驗證

一般資料庫使用者都是資料庫驗證,因為是在資料庫啟動以後才能普通使用者登入

4.資料庫的啟動順序

1.啟動監聽

lsnrctl start;

2.進行sys使用者登入

sqlplus sys/password as sysdba;

conn sys/password as sysdba;

當***監聽到是as sysdba 時候,就進行作業系統和密碼檔案驗證。

3.啟動資料庫(啟動例項)

startup;

4.普通使用者登入

conn scott/tiger;

當資料庫啟動以後,使用者登入的時候就可以使用資料庫驗證。

Oracle許可權管理

oracle中的許可權管理 說明 oracle中許可權分為系統許可權和物件許可權 1.oracle中有3個預設的使用者 1.sys使用者 change on install dba使用者 登入是必須加 as sysdba 2.system使用者 manager 管理員使用者 3.scott使用者 t...

oracle許可權管理

select from system privilege map 檢視系統所有許可權 208種許可權 create user jsx1 identified by 123456 建立使用者jsx1 密碼為123456 create user jsx2 identified by 123456 建立使...

oracle許可權管理

oracle中資料字典檢視分為3大類,用字首區別,分別為 user,all 和 dba,許多資料字典檢視包含相似的資訊。user 有關使用者所擁有的物件資訊,即使用者自己建立的物件資訊 all 有關使用者可以訪問的物件的資訊,即使用者自己建立的物件的資訊加上其他使用者建立的物件但該使用者有權訪問的資...