Oracle Dblink Preliminary use

Source: Internet
Author: User

+---------+
| DB1 |
+---------+
--Create user and authorize
Sqlplus/as SYSDBA
Create user U1 identified by U1 account unlock default tablespace USERS;
Create user U2 identified by U2 account unlock default tablespace USERS;
Grant Connect,resource to U1;
Grant Connect,resource to U2;
Grant create public synonym to U2;
Grant Select on U1.t1 to U2;
Grant Select on U1.t2 to U2;

--U1 Creating a Test table
CREATE TABLE T1 as select * from Scott.emp;
CREATE TABLE t2 as select * from Scott.dept;

--U2 Creating a Test table
CREATE TABLE U2_t1 as SELECT * from Scott.emp;

--Create U1 local synonyms

Create public synonym synonym_t1 for u1.t1;

Create public synonym synonym_t2 for u1.t2;

--Login verification with U2

Conn U2/U2
SELECT * from Synonym_t1;

SELECT * from Synonym_t2;

+---------+
| DB2 |
+---------+
In the Hosts file, join the DB1 record as follows
192.168.1.180 testnode1.osdba.org Testnode1

Sqlplus/as SYSDBA
Create user U3 identified by U3 account unlock default tablespace USERS;
Grant Connect,resource to U3;
Grant CREATE database link to U3;
Grant create public synonym to U3;

--Create Dblink
Create DATABASE link Dbtest1 connect to U2 identified by U2
Using ' (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = testnode1.osdba.org) (PORT = 1521))
(Connect_data =
(SERVER = dedicated)
(service_name = testdb1)
)
)‘;

--Create a remote U2 synonym

Create public synonym synonym_u2_t1 for [email protected]; (U2 own table)

Create public synonym synonym_u2_t2 for [email protected]; (U2 synonyms)

--Verification

SELECT * from Synonym_u2_t1;
SELECT * from Synonym_u2_t2;

Oracle Dblink Preliminary use

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.