Oracle Privileges and Roles
阿新 • • 發佈:2019-01-25
Grant Privileges on Tables
Privilege | Description |
---|---|
Select | Ability to query the table with a select statement. |
Insert | Ability to add new rows to the table with the insert statement. |
Update | Ability to update rows in the table with the update statement. |
Delete | Ability to delete rows from the table with the delete statement. |
References | Ability to create a constraint that refers to the table. |
Alter | Ability to change the table definition with the alter table statement. |
Index | Ability 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;
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 allon suppliers from anderson;
如果你有授權給public(所有使用者),現在想撤權,可以執行:
revoke all on suppliers from public;
Grant Privileges on Functions/Procedures
針對Functions/Procedures的授權。Functions/Procedures的許可權類別Privilege | Description |
---|---|
Execute | Ability 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;