Oracle database to create a read-only users

Create a read-only user user2, can only look-up table in the Admin user user1, not additions and deletions.

Operating environment: PL / SQL Developer

1, with the administrator of user1 login, create user user2, and authorized

- Create a user user1, password 123456 
the Create  the User user2 IDENTIFIED by  123456 ;
 - authorized 
Grant Connect to user2;
 Grant  the Create synonym to user2;
 Grant  the Create the session to user2;

2, user2 grants permission to query the table: Copy the following query results, execution

select 'grant select on '||owner||'.'||object_name||' to user2;'
 from dba_objects
 where owner in ('USER1')
 and object_type='TABLE';

3. Create a synonym for the user2: Copy the following query results, execution

select 'create or replace SYNONYM user2.' || object_name|| ' FOR ' || owner || '.' || object_name|| ';' 
from dba_objects
where owner in ('USER1')
and object_type='TABLE';

 

Test:
with user2 login database, query normal, suggesting additions and deletions do not have permission.

 

Guess you like

Origin www.cnblogs.com/gdjlc/p/11655924.html