Oracle Database Synchronization The test is successful between two Oracle databases. The following is a summary:
Requirements:
There are two Oracle database servers A and B (A and B can be on the same Intranet or two independent machines on the Internet ). Both A and B have testable tables with the same structure. Now, when the testable table in database a changes, the testable data in database B also changes accordingly.
My solutions:
Create a link to database B in database A, create a synonym for the table to be synchronized, and create a trigger. Of course, the current user you are using must have the appropriate permissions to perform these operations.
When synchronizing data from A to B, all settings should be made on:
1. To ensure connection to the database of another remote server, you need to create a DB link. However, pay attention to the syntax format: Using + "connect string ", this connect string should exist in the tnsnames of the Oracle server. in the ora file, listenProgramThe remote server will be retrieved from here
The IP address and other information. I have defined a '123' connect string as follows:
251 = (Description = (Address_list = (Address = (Protocol = TCP) (host = 192.168.0.20.) (Port = 1521 )) ) (CONNECT_DATA = (SERVICE_NAME = mychoice) ) ) |
Store it in your tnsnames. ora file.
2. Then you can define the DB link:
Create public database link test2.us. Oracle. com Connect to user name Identified by "password" Using '000000 '; |
3. Create synonym (synonymous)
Create or replace synonym test01 For MYCHOICE.TESTABLE@TEST2.US.ORACLE.COM; |
After the creation, you can use:
Select * From test01
The preceding statement is equivalent to executing on server B:
Select * From testable
4. feudal triggers:
When the testable table in Table A changes (insert operation is only considered here), the corresponding data will be inserted to the testable of remote database B:
Create or replace trigger rtest After insert on testable For each row Begin Insert into test01 (something) values (: New. Something ); End; |
OK. Now we can test it. you can insert a record to the testable table in database a to see if database B has been added accordingly.
Http://blog.chinaunix.net/u/11317/showart_189040.html