Oracle DB Link

Source: Internet
Author: User
The links between databases are established on the database link. To create a DB link, you must first set the link string on each database server.

1. Configure TNS, $ ORACLE_HOME/Network/admin/tnsname. ora
10 gstandby =
(Description =
(Address = (Protocol = TCP) (host = HFCC-KF-3068) (Port = 1522 ))
(CONNECT_DATA =
(Server = dedicated)
(SERVICE_NAME = 10 gstandby)
)
)

2. Create a database link,
Create public database link db_link_name connect to targetdatabaseusername identified by targetdatabasepassword using 'targetdatabasesidname ';
Note: targetdatabasesidname is the database connection string defined in the tnsnames. ora file on the host where the Oracle database is located.

SQL> Create public database link DVD connect to system identified by system using 'orcl10g'; or use: Create public database link link_name connect to user identified by PWD using '(description =
(Address_list =
(Address = (Protocol = TCP) (host = 192.168.1.1) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)';


A dvd linked to the System user and orcl10g database is created. We query the DVD data:

SQL> select * From all_users @ DVD;

In this way, local and remote data can be processed as a whole.

3. Create synonyms. In order to make distributed operations more transparent, the Oracle database has a synonym object synonym.

SQL> Create synonym syntest for all_users @ DVD;

So we can use syntest to replace the Distributed Link with the @ symbol to operate all_users @ DVD;

4. View All database links:

SQL> select owner, object_name from dba_objects where object_type = 'database link ';

5. view database connections
SQL> select owner, db_link from dba_db_links;
Ower db_link
Public DVD. Regress. RDBMS. Dev. Us. Oracle. com

6. delete a database connection
First, view the database connection in step 1 and obtain the db_link name.
SQL> drop public database link DVD. Regress. RDBMS. Dev. Us. Oracle. com
Database Connection discarded

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.