Implementation of batch Oracle authorization

Source: Internet
Author: User

Oracle batch authorization can implement some specific functions: two users, one of which has no data structure. User A can access all data of user B through user A, and only has the permission to read data, the data structure of user B is invisible and can only be queried.

1. Create read-only user:

 
 
  1. -- Create the user  
  2. create user A  
  3. identified by ""  
  4. default tablespace LMIS  
  5. temporary tablespace LMIS  
  6. profile DEFAULT;  
  7.  

2. grant corresponding permissions to Aas (executed under user B with DBA permission)

 
 
  1. grant create session to A;  
  2. grant create synonym to A; 

3. Execute the following statement commit window as owner B)

 
 
  1. Set heading OFF;
  2. Set feedback OFF;
  3. SPOOL c: \ temp \ A. SQL; -- path to the file
  4. SELECT 'create synonym' | tname | 'for B.' | tname | ';' FROM TAB;
  5. Spool off;

4. Change to the identity of authorized user A and execute

 
 
  1. @c:\temp\A.SQL 

5. Grant user A permissions (executed in the COMMIT window of user B)

 
 
  1. set heading OFF;  
  2. set feedback OFF;  
  3. SPOOL c:\grantA.SQL;  
  4. SELECT 'grant select,insert,update,delete,REFERENCES,INDEX on ' ||  
  5.  TNAME || ' to A;'  
  6. FROM TAB WHERE TABTYPE <>'VIEW'  
  7. UNION ALL  
  8. SELECT 'grant select,insert,update,deleteon ' || OBJECT_NAME ||  
  9.  ' to A;'  
  10. FROM USER_OBJECTS  
  11.  WHERE OBJECT_TYPE = 'VIEW' 
  12. UNION ALL  
  13. SELECT 'grant EXECUTEon ' || OBJECT_NAME || ' to A;'  
  14. FROM USER_OBJECTS  
  15.  WHERE OBJECT_TYPE = 'PROCEDURE' 
  16. UNION ALL  
  17. SELECT 'grant EXECUTEon ' || OBJECT_NAME || ' to A;'  
  18. FROM USER_OBJECTS  
  19.  WHERE OBJECT_TYPE = 'FUNCTION' 
  20. UNION ALL  
  21. SELECT 'grant selecton ' || OBJECT_NAME || ' to A;'  
  22. FROM USER_OBJECTS  
  23.  WHERE OBJECT_TYPE = 'SEQUENCE';  
  24.  
  25.  SPOOL OFF;  

6. execute scripts

 
 
  1. @c:\grantA.SQL; 

Three oracle authorizations

Implementation of oracle tree Query

Implementation of oracle query current time

Provides you with an in-depth understanding of Oracle temporary tables

How to store images in oracle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.