首页 > 解决方案 > 将所有用户表的读取权限授予oracle中的新用户

问题描述

oracle中如何将所有用户表的读取权限提供给新用户?

标签: oracle

解决方案


一个接一个,没有魔法命令可以“一次”完成。

每个用户都应该运行

grant select on my_first_table to a_new_user;

声明。


没错,您可以编写代码来为您编写代码,例如

SQL> select 'grant select on ' || tname || ' to a_new_user;' as command
  2  from tab
  3  order by tname;

COMMAND
-------------------------------------------------------------
grant select on BONUS to a_new_user;
grant select on CHALLEN_HEADER to a_new_user;
grant select on CONFIG to a_new_user;
grant select on CUSTOMER to a_new_user;  
<snip>

现在将那一堆GRANT语句复制/粘贴到您的客户端(SQL*Plus、SQL Developer 等)并运行它们。

或者,您可以将该语句的结果假脱机到一个文件中,然后运行该文件。

或者,甚至创建一个 PL/SQL(匿名?存储?)过程,该过程将接受一个参数 - 一个新用户的名称 - 并一次性授予权限。


推荐阅读