Data Synchronization steps for remote Oracle databases

Source: Internet
Author: User

The main purpose of Data Synchronization in A remote Oracle database is to change the TBL_TB data in table A of the Oracle database of server, the table TBL_TB in the Oracle database B of server B also changes accordingly. (assume that the two tables have the same structure and contain only the ID and NAME columns ).

Procedure:

1) create a connection configuration: Add a connection to server B in network/admin/tnsnames. ora under the Oracle database installation directory of server:

 
 
  1. MASTER2 =  
  2. (DESCRIPTION =  
  3. (ADDRESS_LIST =  
  4. (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521))  
  5. )  
  6. (CONNECT_DATA =  
  7. (SERVICE_NAME = master2)  
  8. )  
  9. )  

Assume that the IP address of a is 192.168.0.1, the IP address of B is 192.168.0.2, And the Oracle Database Service name of B is master2, and the port number of B is 1521.

2) create a DBLINK:

 
 
  1. create public database link LINKMASTER2.Oracle.COM 

Connect to user name -- the user name used to connect to Oracle Database in B. We should fill in B this time.

Identified by "password" -- password (do not remove double quotation marks)

 
 
  1. using 'MASTER2'; 

3) create a synonym: Create a synonym for convenience.

 
 
  1. create or replace synonym TESTLINK  
  2. for B.TBL_TB@LINKMASTER2.Oracle.COM;  

4) create a trigger:

Create A trigger under TBL_TB under database space A in server A, which is responsible for insertion and synchronization. The trigger's main part is as follows:

 
 
  1. begin  
  2. insert into TESTLINK (id,name) values (:new.id,:new.name);  
  3. end;  

Create A trigger under TBL_TB under Oracle database space A in server A to modify and synchronize the trigger:

 
 
  1. begin  
  2. update TESTLINK set id=:new.id,name=:new.name where id= :old.id;  
  3. end;  

Assume that the ID column is unique.

Action summary report:

2nd) and 3) Steps should be SQL statements executed in the environment of Data User A of server.

After creating a synonym, you can directly query the table content of a remote database: select * from TESTLINK;

Note that the firewall of server B must be disabled. Otherwise, a timeout error will be reported during connection establishment.

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.