创建用户并授权

CREATE USER test identified by mL7TTD5XIt;
grant connect to test;
grant create view to test;
grant create session to test;
grant create synonym to test;

将其他可查询的账号的权限提取出来

select 'grant select on '||owner||'.'||object_name||' to test;' from dba_objects where owner in ('OLD_USER') and object_type='TABLE';

执行后得到返回值如下: image.png

将返回值复制出来进行执行

image.png

在新账号端创建同位显示表

因为新创建的只读账号,Tables栏中显示为空,我们需要在PL/SQL显示栏中为新账号登录界面添加显示同位元素,如下:

select 'create or replace SYNONYM test.'||object_name|| ' for ' ||owner|| '.'||object_name||';' from dba_objects where owner in ('OLD_USER') and object_type='TABLE';

得到返回值如下: image.png

执行返回值

image.png

结果验证

使用刚创建的账号登陆,登陆某一行的数据,提示权限不足 image.png

参考链接:https://www.jb51.net/article/214232.htm