问题
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 GRANT
s 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