How to Create a DB Link for an Oracle database to operate a remote database

Source: Internet
Author: User

OracleOperationRemote databaseYou can useCreate a DB LinkThis document describes the creation process in detail. Now let's get started. Assume that the local IP address is 192.168.1.11, database instance orcl, User name: tysp, password: test Remote database IP Address: 192.168.1.52, database instance lntysp, User name: tysp, password: 12345678.

1. Create a DB Link to operate a remote database

Statement: create database link TEST_DBLINK.REGRESS.RDBMS.DEV.US.ORACLE.COM

Run the following command:

 
 
  1. connect to tysp identified by "12345678"  
  2.  
  3. using '192.168.1.52/lntysp';  

In the base, TEST_DBLINK is the name of the DB Link we get. Oracle will automatically add the next letter,

Graph in PL/SQL:

2. After the database is created, you can operate the remote database.

1. Insert data:

 
 
  1. Insert into p_sys_log @ TEST_DBLINK values ('123456', '1234568', 'title', sysdate, 'content', '1', '1234568 ');
  2.  
  3. Commit;

2. query data: select t. * from p_sys_log @ TEST_DBLINK t;

3. delete data:

 
 
  1. delete from p_sys_log@TEST_DBLINK t where t.id='1111';  
  2.  
  3. commit; 

3. You can also create synonyms for DB Link to facilitate data operations.

Create or replace synonym TEST_DBLINK_SYNfor;

PL/SQL:

In this case, you can access the synonym to operate the remote database (the P_SYS_LOG table is used as an example ):

1. Add data:

 
 
  1. Insert into TEST_DBLINK_SYN values ('20140901', '20160901', 'title', sysdate, 'content', '2', '20160301 ');
  2.  
  3. Commit;

2. query data: select t. * from TEST_DBLINK_SYN t;

3. delete data: delete from TEST_DBLINK_SYN t where t. id = '000000 ';

This article introduces how to create a database Link for Oracle databases to operate remote databases. I hope this introduction will bring you some benefits. Thank you!

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.