The required information: Create a dblink from the MM Library to the GG Library
The username and password of the MM library are mmn and mmk.
The user name and password of the GG library are ggn and ggk.
Prerequisites: The MM database has the permission to establish dblink, And the hosts on both sides can be pinged.
Step 1:
First, query the global_name of the two databases.
Select * from global_name;
For example, the MM database is MMDB, And the GG database is GGDB.
Setp2:
Create dblink
-- Create database link
Create database link MMDB. GGDB. QHLIFE. COM -- dblink name, which is generally the global_name of the two databases and the domain name of the company.
Connect to GGN identified by "ggk" -- the username and password of the database to be connected. The password is case-sensitive with double quotation marks.
Using '(DESCRIPTION = -- TNS information of the database to be connected
(ADDRESS = (PROTOCOL = TCP) (HOST = 10.50.64.187) (PORT = 1521 ))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = zjuat ))
)';
Step 3:
Check whether the connection is successful.
Select * from dual@MMDB.GGDB.QHLIFE.COM;
Note: delete the dblink statement.
Drop database link MMDB. GGDB. QHLIFE. COM;
If @ dblink is used for query every time, we can use synonyms.
The created statement is to create an alias for the remote table.
Create synonym GGTABLE for GGDB_TABLE@MMDB.GGDB.QHLIFE.COM;
GGTABLE is the name to be used later
GGDB_TABLE@MMDB.GGDB.QHLIFE.COM is the name of the remote table