Thursday, May 31, 2018

How to Create a Read Only Schema in Oracle R12


How to Create a Read Only Schema in Oracle R12. 


Method :1 

SQL> CREATE USER XXTEST IDENTIFIED BY XXTEST ;   
User created. 
SQL> 

SQL> GRANT CONNECT, RESOURCE,CREATE SYNONYM TO XXTEST ;
Grant succeeded.   
SQL> 

Generate a Script for creating database objects of Application User ‘APPS’

set echo off set
pagesize 0
set linesize 300
spool CREATEsynonyms.sql
select 'create synonym ' || OBJECT_NAME || ' for '|| OWNER ||'.' ||OBJECT_NAME || ';' from all_objects where OWNER in ('APPS') and 
OBJECT_NAME not like '%/%' and OBJECT_TYPE in ('TABLE','VIEW','SYNONYM');   
spool off 



Generate a script for selecting database objects of Application User ‘APPS’


spool GrantSelect.sql   
select 'grant select on '|| OWNER ||'.' ||OBJECT_NAME || ' to XXTEST ;' from all_objects  where OWNER not in ('SYS','SYSTEM') and OBJECT_NAME not like '%/%' and OBJECT_TYPE in ('TABLE','VIEW','SYNONYM');   
spool off 


Connect to sqlplus  as sysdaba and execute the following script

SQL> @GrantSelect.sql 
SQL> @CREATEsynonyms.sql 

Connect to Read only schema User and check the objects.

SQL> conn oracle/oracle Connected. 
SQL> select count(*) from tab;     

No comments: