How to create to Oracle DB User which is like APPS but has only SELECT privileges (this user should not have to use schema name.objectname and all SELECT qeries run from APPS user should work from this DB User as well)
a. Create a user using
Create user ‘username’ identified by ‘password’;
b. Then execute the following command in the sql prompt as the sys user,
spool create_grants.sql
set echo off
set pagesize 0
set linesize 300
set feedback off
SELECT 'Grant select on APPS.'||object_name||' to A;' FROM user_objects WHERE object_type IN ('TABLE','VIEW');
spool off;
exit;
c. Executing the script would create a sql file name create_grants.sql that has all the ‘SELECT priveleges’ of all the objects that the APPS user has access to..
d. Finally run the create_grants.sql script.
Or
->run the below commands :-
BEGIN
FOR R IN (SELECT owner, table_name FROM all_tables WHERE owner='APPS') LOOP
EXECUTE IMMEDIATE 'grant select on '||R.owner||'.'||R.table_name||' to A ';
END LOOP;
END;
/
BEGIN
FOR R IN (SELECT owner, view_name FROM all_views WHERE owner='APPS') LOOP
EXECUTE IMMEDIATE 'grant select on '||R.owner||'.'||R.view_name||' to B ';
END LOOP;
END;
a. Create a user using
Create user ‘username’ identified by ‘password’;
b. Then execute the following command in the sql prompt as the sys user,
spool create_grants.sql
set echo off
set pagesize 0
set linesize 300
set feedback off
SELECT 'Grant select on APPS.'||object_name||' to A;' FROM user_objects WHERE object_type IN ('TABLE','VIEW');
spool off;
exit;
c. Executing the script would create a sql file name create_grants.sql that has all the ‘SELECT priveleges’ of all the objects that the APPS user has access to..
d. Finally run the create_grants.sql script.
Or
->run the below commands :-
BEGIN
FOR R IN (SELECT owner, table_name FROM all_tables WHERE owner='APPS') LOOP
EXECUTE IMMEDIATE 'grant select on '||R.owner||'.'||R.table_name||' to A ';
END LOOP;
END;
/
BEGIN
FOR R IN (SELECT owner, view_name FROM all_views WHERE owner='APPS') LOOP
EXECUTE IMMEDIATE 'grant select on '||R.owner||'.'||R.view_name||' to B ';
END LOOP;
END;
No comments:
Post a Comment