Create the DBLINK - Tested & Verified

Create the Simple DBLINK

Consider DB Scenario:

SID: testdb1 (Source DB), SID: testdb2 (Target DB), Table: t1

Create Database Links

On each server create a database link to the other database.
On the source server (testdb1) as the mir user, create the following database link:

[oracle@testdb1]$ sqlplus mir/mir
SQL> CREATE DATABASE LINK testdb2 CONNECT TO mir IDENTIFIED BY mir USING 'testdb2';

On the target server (testdb2) as the mir user, create the following database link:

[oracle@testdb2]$ sqlplus mir/mir
SQL> CREATE DATABASE LINK testdb1 CONNECT TO mir IDENTIFIED BY mir USING 'testdb1';

Create a table with record in source db (testdb1) & create the only structure in target db (testdb2)

$ sqlplus mir/mir

SQL> create table t1(eno number(10));
SQL> insert into t1 values(1);     -- Similary insert for total 5 records
SQL> select count(*) from t1;
                   5 
SQL> commit;

Copy Test Data to Target Database

Create an initial copy of the test data on the target database

In the target database (testdb2) create a copy of the T1 table using the SQL*Plus command:

[oracle@testdb2]$ sqlplus mir/mir
SQL> CREATE TABLE t1 AS SELECT * FROM t1@testdb1;

In the target database (testdb2), add a primary key constraint and index to table T1:

[oracle@testdb2]$ sqlplus mir/mir
SQL> ALTER TABLE t1 ADD CONSTRAINT t1_i1 PRIMARY KEY (object_id);

In the source database (testdb2), verify the number of rows in the original table:

[oracle@testdb1]$ sqlplus mir/mir
SQL> SELECT COUNT(*) FROM t1;

COUNT(*)
--------
5

In the target database, verify that there is the same number of rows in the new table:

[oracle@testdb2]$ sqlplus mir/mir
SQL> SELECT COUNT(*) FROM t1;

COUNT(*)
--------
5

Hence tested with vice versa - Works Fine 

Note that the actual number of rows in table T1 should be identical for databases testdb1 and testdb2 However, it may vary in other database as per the record.

      If there is any clarification, Please revert me back 24/7, E-mail: sayeed202@gmail.com






Comments

Popular posts from this blog

RAC Failure Scenario - Testing in our RAC Test DB - Node 1 & Node 2

ORA-01110: data file 1: '/oradata/datafiles/system01.dbf'

Expdp from Higher version 12c (12.1.0.2) to lower version 11g (11.2.0.4)