Synchronize and copy data from a remote Oracle Server to a local backup database

Source: Internet
Author: User

Synchronize and copy data from a remote Oracle Server to a local backup database

Create or replace PROCEDURE "SYNC_DATA_FROM_DBLINK_DB"
BEGIN
DECLARE
CURSOR c_TabNames IS
Select tname from tab;
V_TabName c_TabNames % ROWTYPE;
V_ SQL VARCHAR2 (500 );
V_rowcount NUMBER;
V_rc NUMBER: = 0;
V_tab NUMBER: = 0;
BEGIN
Dbms_Output.put_line (to_char (SYSDATE, 'yy-mm-dd hh24: mi: ss') | 'start to import the table from a remote TEST2 instance .');
FOR v_TabName in c_TabNames LOOP
V_ SQL: = 'delete' | v_TabName.TNAME;
Execute immediate v_ SQL;
V_ SQL: = 'insert' | v_tabname.TNAME | 'select * from' | v_tabname.TNAME | '@ test2 ';
Execute immediate v_ SQL;
COMMIT;
V_ SQL: = 'select COUNT (*) from' | v_tabname.TNAME;
Execute immediate v_ SQL INTO v_rowcount;
V_tab: = v_tab + 1;
V_rc: = v_rc + v_rowcount;
End loop;
Dbms_Output.put_line (to_char (SYSDATE, 'yy-mm-dd hh24: mi: ss') | 'import completed, total import table' | to_char (v_tab) |, total number of records '| to_char (v_rc) |' records. ');
END;
END SYNC_DATA_FROM_DBLINK_DB;

Related Article

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.