DB-hub Technology Oracle Create Role and grant to user

Create Role and grant to user

Traget:

grant user abc with read only access to all the table&view schema def.
set pages 5000
set linesize
create role def_RO;

spool def_grant.sql
select 'grant select on ' || owner || '.' || table_name || ' to def_RO;' from dba_tables where onwer='def';
select 'grant select on ' || owner || '.' || view_name || ' to def_RO;' from dba_views where owner='def';
spool off

sed -e 's/ *//' -e '/^ */d' def_grant.sql > def_grant2.sql

@def_grant2.sql

grant def_RO to abc;

Leave a Reply

您的邮箱地址不会被公开。 必填项已用 * 标注

Related Post