I want to move records from one database to another for archiving purposes.
So I created a db link and a synonym on archiving server pointing to the production server like this:
CREATE Public Database Link Prod_Link Connect to myuser IDENTIFIED BY "mypass" Using 'MyTnsName';
CREATE Public SYNONYM DocsProd FOR myuser.Docs@Prod_Link;
I want to run the following sql statements on archiving server to move the records:
INSERT INTO myuser.Docs
SELECT * FROM DocsProd WHERE ID<1000000;
DELETE FROM DocsProd WHERE ID<1000000;
COMMIT;
I have two questions:
1. Would it be faster to do it the other way around? What I mean is create db link on Production Server to point to the archive and run the sql on production server.
2. How can I be sure that the transaction is rollbacked if an error occurs during the insert or delete statement?
So I created a db link and a synonym on archiving server pointing to the production server like this:
CREATE Public Database Link Prod_Link Connect to myuser IDENTIFIED BY "mypass" Using 'MyTnsName';
CREATE Public SYNONYM DocsProd FOR myuser.Docs@Prod_Link;
I want to run the following sql statements on archiving server to move the records:
INSERT INTO myuser.Docs
SELECT * FROM DocsProd WHERE ID<1000000;
DELETE FROM DocsProd WHERE ID<1000000;
COMMIT;
I have two questions:
1. Would it be faster to do it the other way around? What I mean is create db link on Production Server to point to the archive and run the sql on production server.
2. How can I be sure that the transaction is rollbacked if an error occurs during the insert or delete statement?