Chủ Nhật, 29 tháng 11, 2020

Chuyển 1 schema sử dụng datapump và dbms_file_transfer trong Oracle Database

Chuyển schema test_owner bằng file_transfer


1. Export dữ liệu
SQL> SELECT * FROM dba_directories;
SQL> create or replace directory GW='+reco_gold/dbaviet/dump';
-- create or replace directory subs as '/u03/subs/';
expdp userid=\"/ as sysdba\" dumpfile=test_owner_%u.dmp schemas=test_owner parallel=16 directory=GW NOLOGFILE=y


2. Chuyển file dump tới DB dest bằng dblink
• C1: Chuyển file dump tới DB dest bằng dblink
BEGIN
  DBMS_FILE_TRANSFER.put_file(
   source_directory_object      => 'DB_FILES_DIR1',
   source_file_name             => 'USERS01.DBF',
   destination_directory_object => 'DB_FILES_DIR2',
   destination_file_name        => 'USERS01.DBF',
   destination_database         => 'REMOTE');
END;
/
--REMOTE: ten db_link

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_01.dmp','dbaviet', 'test_owner_01.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_02.dmp','dbaviet', 'test_owner_02.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_03.dmp','dbaviet', 'test_owner_03.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_04.dmp','dbaviet', 'test_owner_04.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_05.dmp','dbaviet', 'test_owner_05.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_06.dmp','dbaviet', 'test_owner_06.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_07.dmp','dbaviet', 'test_owner_07.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_08.dmp','dbaviet', 'test_owner_08.dmp','dbaviet' );
END;
/

BEGIN
    --
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_09.dmp','dbaviet', 'test_owner_09.dmp','dbaviet' );
END;
/


BEGIN
    --
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_10.dmp','dbaviet', 'test_owner_10.dmp','dbaviet' );
END;
/

BEGIN
    --
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_11.dmp','dbaviet', 'test_owner_11.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_12.dmp','dbaviet', 'test_owner_12.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_13.dmp','dbaviet', 'test_owner_13.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_14.dmp','dbaviet', 'test_owner_14.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_15.dmp','dbaviet', 'test_owner_15.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_16.dmp','dbaviet', 'test_owner_16.dmp', 

'dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_17.dmp','dbaviet', 'test_owner_17.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_18.dmp','dbaviet', 'test_owner_18.dmp','dbaviet' );
END;
/

BEGIN
    DBMS_FILE_TRANSFER.PUT_FILE('gw', 'test_owner_19.dmp','dbaviet', 'test_owner_19.dmp','dbaviet' );
END;
/
• C2: Chuyển bằng SCP
scp /u01/binhtv/* oracle@192.168.1.10:/export/home/oracle/binhtv
3. Import dữ liệu
impdp userid=\"/ as sysdba\" directory=tmpdump DUMPFILE=test_owner_%U.dmp parallel=16 TABLE_EXISTS_ACTION=APPEND DATA_OPTIONS=SKIP_CONSTRAINT_ERRORS


KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH: 📧 Mail: binhoracle@gmail.com ☎️ Mobile: 0902912888 ⚡️ Skype: tranbinh48ca 👨 Facebook: https://www.facebook.com/BinhOracleMaster 👨 Inbox Messenger: https://m.me/101036604657441 (profile) 👨 Fanpage: https://www.facebook.com/tranvanbinh.vn 👨 Inbox Fanpage: https://m.me/tranvanbinh.vn 👨👩 Group FB: https://www.facebook.com/groups/OracleDBAVietNam 👨 Website: http://www.tranvanbinh.vn 👨 Blogger: https://tranvanbinhmaster.blogspot.com 🎬 Youtube: http://bit.ly/ytb_binhoraclemaster 👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi 👨 Linkin: https://www.linkedin.com/in/binhoracle 👨 Twitter: https://twitter.com/binhoracle 👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội #OracleTutorial #OracleDBA #OracleDatabaseAdministration #học oracle database #oca #ocp #oce #ocm

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master