1.创建数据库目录

源库,目标pdb库
注意目标数据库目录需要在目标容器创建而不是cdb下

  1. mkdir /opt/oracle/mydump -p
  2. create directory mydump as '/opt/oracle/mydump';
  3. grant read on directory mydump to public;
  4. grant write on directory mydump to public;

2.设置表空间为只读

  1. alter TABLESPACE fixf read only;

3.执行一致性检查

  1. exec sys.dbms_tts.transport_set_check('fixf',TRUE,TRUE);
  2. select * from transport_set_violations;

4.导出表空间

  1. expdp sys/12345 dumpfile=exp.dmp directory=mydump tablespaces=fixf transport_full_check=y logfile=fixf.log;
  2. Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
  3. Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": sys/******** AS SYSDBA dumpfile=exp.dmp directory=mydump transport_tablespaces=fixf transport_full_check=y logfile=fixf.log
  4. Processing object type TRANSPORTABLE_EXPORT/INDEX/STATISTICS/INDEX_STATISTICS
  5. Processing object type TRANSPORTABLE_EXPORT/STATISTICS/TABLE_STATISTICS
  6. Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
  7. Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
  8. Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
  9. Processing object type TRANSPORTABLE_EXPORT/TABLE
  10. Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX
  11. Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
  12. Processing object type TRANSPORTABLE_EXPORT/COMMENT
  13. Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
  14. ******************************************************************************
  15. Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is:
  16. /opt/oracle/mydump/exp.dmp
  17. ******************************************************************************
  18. Datafiles required for transportable tablespace FIXF:
  19. /opt/oracle/oradata/ORCL/datafile/o1_mf_fixf_hbzdq923_.dbf
  20. Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at Thu Sep 17 10:46:12 2020 elapsed 0 00:01:27

5.创建到pdb的dblink

  1. create public database link fixfpdb_link
  2. connect to c##fixf IDENTIFIED by "12345"
  3. using '192.168.5.129/fixfpdb';

6.传输数据文件

或者手工cp

  1. BEGIN
  2. dbms_file_transfer.put_file(source_directory_object => 'mydump'
  3. ,source_file_name => 'exp.dmp'
  4. ,destination_directory_object => 'mydump'
  5. ,destination_file_name => 'exp.dmp'
  6. ,destination_database => 'fixfpdb_link');
  7. END;
  8. /

7.目标库创建准备导入的表空间

  1. create tablespace fixf;

8.导入数据

注意替换用户

  1. impdp c##fixf/12345@192.168.5.129:1521/fixfpdb directory=mydump dumpfile=exp1.dmp logfile=fixf_imp.log REMAP_SCHEMA=fixf:c##fixf;

9.修改原表空间为读写

  1. alter tablespace fixf read write;