Authorization of oracle learning records (2)

Source: Internet
Author: User

Oracle Learning Record authorization (2) oracle Learning Record and authorization. New Requirement: grant the query permission of all tables of a user to another user. Authorization using oracle learning records (1) Table-by-table authorization is time-consuming and laborious. Www.2cto.com idea: Use all table names to construct a grant statement, copy, paste, and execute the statement, and save time. The exercise process is as follows: 1. Prepare the sys user to connect to the database: connect sys/oracle as sysdba; create test1 and test2 users: create user test1 identified by 123; create user test2 identified by 123; grant the dba role to test1: grant the dba to test1; the dba role has too many permissions. revoke the dba role: revoke dba from test1; grant the test1 and test2 user the permission to create a session: grant create session to test1, test2; grant test1 users the permission to create tables and possess resources: grant create table, resource to test1; www.2cto.com test1 users connect to the database, create tables, and insert data: connect test1/123; create table a (a n Umber (10); create table B (B number (10); create table c (c number (10); insert into a values (1 ); insert into B values (2); insert into c values (3); commit; query tables of the owner with a total of five characters starting with test in the view all_tables: -- convert upper and lower case to select owner, table_name from all_tables where lower (owner) like 'test _ '; 2. Grant the query permission on all tables of test1 to test2: 1. log on to sys 2. Run the following statement: -- test1 is the user with the table, test2 is the authorized user, | is the connector select 'Grant select on' | lower (table _ Name) | 'to test2;' from all_tables where owner = upper ('test1'); 3. Copy the preceding query result (as follows) and paste it for execution, finally, press enter to execute the last sentence. Grant select on a to test2; grant select on B to test2; grant select on c to test2; 3. Test authorization successful: connect test2/123 select * from test1.a; select * from test1. B; select * from test1.c;

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.