Synonyms used in Oracle

Source: Internet
Author: User
Tags commit

I. BACKGROUND

There are two sid:asid,bsid, two user auser1,auser2 under Asid, and a user Buser1 under Bsid. Among them Auser2 and Buser1 established the Dblink. You now want to access the three tables Table1,table2,table3 information and function function1 on Auser1 by logging on to Buser1.

Second, the steps

① login Auser1 to Auser2 authorization (plus delete if you need to delete)

Grant Insert,select,update on Table1 to Auser2;

Grant Insert,select,update on table2 to Auser2;

Grant Insert,select,update on Table3 to Auser2;

Grant execute on function1 to Auser2;

② Login Auser2 Establish synonyms

Create synonym table1 for auser1.table1;

Create synonym table2 for auser1.table1;

Create synonym Table3 for auser1.table1;

Create synonym function1 for auser1.function1;

③ login Buser1 Find Db_link name (for example, Db_link named Mydblink1)

Select Username,db_link from User_db_links

④ establish a synonym for Buser1

Create synonym table1 for auser2.table1@mydblink1;

Create synonym table2 for auser2.table2@mydblink1;

Create synonym Table3 for auser2.table3@mydblink1;

Create synonym function1 for auser2.function1@mydblink1;

⑤ Test

At this point, the login Buser1 can access table1 through the SELECT * from table1.

Third, the attention point

You can also establish synonyms for procedure, but no commit is allowed during this execution. If you want to submit, commit () in JDBC.

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.