Read-only user Creation in Oracle
Created the script with the help of spool by selecting the tables of the HR schemas .
oracle configurationintermediate
by OracleDba
12 views
Created the script with the help of spool by selecting the tables of the HR schemas .
12345678910
SQL> create user PDBUSER identified by PDBUSER;
User created.
SQL> grant create session ,create synonym to PDBUSER ;
Grant succeeded.
SQL> SPOOL select_privs.sql
SQL> select 'grant select on hr.'||table_name|| ' to PDBUSER;' from dba_tables where owner='HR';
SQL> select 'grant select on hr.'||view_name|| ' to PDBUSER;' from dba_views where owner='HR';
SQL> spool off12345678910111213141516
SQL> @select_privs.sql
grant select on hr.REGIONS to PDBUSER;
grant select on hr.LOCATIONS to PDBUSER;
grant select on hr.DEPARTMENTS to PDBUSER;
grant select on hr.JOBS to PDBUSER;
grant select on hr.EMPLOYEES to PDBUSER;
grant select on hr.JOB_HISTORY to PDBUSER;
grant select on hr.COUNTRIES to PDBUSER;
grant select on hr.EMP_DETAILS_VIEW to PDBUSER;
SQL> conn PDBUSER/PDBUSER@orcl
SQL> SPOOL synonym_privs.sql
SQL> select 'create synonym '||view_name|| ' for HR.'||view_name||';' from all_views where owner='HR';
SQL> select 'create synonym '||table_name|| ' for HR.'||table_name||';' from all_tables where owner='HR';
SQL> spool off12345678910111213141516
SQL>@synonym_privs.sql
SQL> select Count(*) from employees ;
COUNT(*)
----------
107
SQL> select Count(*) from hr.employees;
COUNT(*)
----------
107
SQL> show user
USER is "PDBUSERPlease to add comments
No comments yet. Be the first to comment!