怎么指定用户只能访问某一个表空间所有内容?

frogshero 2005-01-12 05:01:39
不要对每一个表都执行grant select ,grant insert 吧?
...全文
225 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
NinGoo 2005-01-12
  • 打赏
  • 举报
回复
或者写成一个存储过程

create or replace procedure grant_on_tablespace
(tb_name in varchar2,user_name in varchar2)
is
begin
for rec in (select table_name,OWNER
from all_tables
where tablespace_name=tb_name)
loop
execute immediate 'grant select on '||rec.table_name||' to '||user_name;
end loop;
end grant_on_tablespace;

/*调用*/

grant_on_tablespace ('tablespace_name','user_name')
NinGoo 2005-01-12
  • 打赏
  • 举报
回复
更正一下
select 'grant select on '||table_name||' to user_name' from all_tables where tablespace_name='USERS';
NinGoo 2005-01-12
  • 打赏
  • 举报
回复
select 'grant select on '||table_name from all_tables where tablespace_name='USERS';

上述语句可以获得授权select所有users表空间的table的权限的语句,可以先spool c:\test.sql,然后修改执行test.sql即可
fuxia 2005-01-12
  • 打赏
  • 举报
回复
grant select,insert on 'select table_name from ' || tablespace_name to user_name;

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧