1. 程式人生 > >Oracle Privileges and Roles

Oracle Privileges and Roles

Grant Privileges on Tables


PrivilegeDescription
SelectAbility to query the table with a select statement.
InsertAbility to add new rows to the table with the insert statement.
UpdateAbility to update rows in the table with the update statement.
DeleteAbility to delete rows from the table with the delete statement.
ReferencesAbility to create a constraint that refers to the table.
AlterAbility to change the table definition with the alter table statement.
IndexAbility to create an index on the table with the create index statement.

語法:

grant privileges on object to user;
比如:如果你想把suppliers表的查詢,插入,修改,刪除的許可權付給使用者smithj,你可以執行下邊的語句
grant select, insert, update, delete on suppliers to smithj;
你也可以直接使用all關鍵字來賦權,表示你想把物件所有的許可權付給某個使用者,比如:
grant all on suppliers to smithj;
如果你想讓所有使用者都可以查詢某張表,那你可以使用public關鍵字,比如:
grant select on suppliers to public;

Revoke Privileges on Tables


授權(Grant)之後,你想取消授權,那就得revoke了。

語法:

revoke privileges on object from user;
比如,你想取消anderson刪除supplier表的權利,可以執行:revoke delete on suppliers from anderson;你想取消anderson針對supplier表的所有權利,可以執行:
revoke all
on suppliers from anderson;

如果你有授權給public(所有使用者),現在想撤權,可以執行:

revoke all on suppliers from public;

Grant Privileges on Functions/Procedures

針對Functions/Procedures的授權。Functions/Procedures的許可權類別
PrivilegeDescription
ExecuteAbility to compile the function/procedure.Ability to execute the function/procedure directly.

語法:

grant execute on object to user;
把Funciton Find_Value的執行許可權付給使用者smithj,可以執行:grant execute on Find_Value to smithj;把Funciton Find_Value的執行許可權付給所有使用者,可以執行:
grant execute on Find_Value to public;

Revoke Privileges on Functions/Procedures

針對Functions/Procedures的撤權。

語法:

revoke execute on object from user;

撤銷anderson針對Find_Value Funciton的執行許可權,可以執行:

revoke execute on Find_Value from anderson;
如果你賦權過所有使用者,現在想撤銷,可以執行:
revoke execute on Find_Value from public;