Sunday, September 15, 2013

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 APPSREAD IDENTIFIED BY APPSREAD;   
User created. 
SQL> 

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

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

set echo off set
pagesize 0
set linesize 300
spool cr8synonyms.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 APPSREAD;' 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> @cr8synonyms.sql 

Connect to Read only schema User and check the objects.

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

No comments:

Post a Comment