Create dblink and synonym in Oracle

Source: Internet
Author: User

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

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.