Oracle SQL privelege authorization on multiple attributes and tables with one statement

萝らか妹 提交于 2019-12-01 07:12:40

问题


Is it possible to grant different privileges on different tables or attributes within the one statement?

For example I want to combine:

GRANT SELECT ON tbl TO user;

and

GRANT UPDATE OF attr ON tbl TO user;

Furthermore, could I combine granting privilege on a different relation:

GRANT INSERT ON tbl2;

All in the one statement.


回答1:


You can combine multiple object privileges in one GRANT, but only for the same object. For example:

GRANT SELECT, UPDATE(column1, column2), INSERT on TBL to user;

But, as you can see in the manual's syntax diagram, each GRANT can only operate on one object at a time.

However, you can run multiple GRANTs as a single statement if you use the CREATE SCHEMA syntax.

CREATE SCHEMA AUTHORIZATION owner_user
GRANT SELECT ON TBL TO user
GRANT SELECT ON TBL2 TO user;

If you're looking to simplify your code, this won't help. But if you have some technical requirement to use a single statement, it may work. For example, I've often found that combining DDL statements can significantly reduce the time it takes to run install scripts, especially over a slow network.



来源:https://stackoverflow.com/questions/13106087/oracle-sql-privelege-authorization-on-multiple-attributes-and-tables-with-one-st

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!