Wednesday, April 24, 2013

Copy a Oracle table from one Database to other


Copy a Oracle table from one Database to other


We have two Data bases:  PROD1 DB and PROD2 DB
Table name: Employee
Schema is same in both DBs

We need to sync Employee table from PROD1 DB to PROD2 DB.

1) Create a DB link between PROD1 and PROD2 DBs - assume it is dblink12
2) Create Employee table in PROD2 DB if it doesn't exist
3)  Run below SQL statement in PROD2 DB

TRUNCATE TABLE .EMPLOYEE;
INSERT INTO EMPLOYEE select * FROM EMPLOYEE@dblink12;

and finally don't forget to run commit.

commit;