本文介绍了使用一条语句对多个属性和表进行Oracle SQL特权授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在一个语句中对不同的表或属性授予不同的特权?

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

例如,我想合并:

GRANT SELECT ON tbl TO user;

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.

推荐答案

您可以在一个GRANT中组合多个对象特权,但只能用于同一对象.例如:

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;

但是,正如您在手册的语法图,每个GRANT一次只能操作一个对象.

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

但是,如果使用CREATE SCHEMA语法,则可以将多个GRANT作为单个语句运行.

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;

如果您想简化代码,这将无济于事.但是,如果您对使用单个语句有一些技术要求,则可能会起作用.例如,我经常发现结合DDL语句可以大大减少运行安装脚本所需的时间,尤其是在网络速度较慢的情况下.

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.

这篇关于使用一条语句对多个属性和表进行Oracle SQL特权授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!