1.创建数据库目录
源库,目标pdb库
注意目标数据库目录需要在目标容器创建而不是cdb下
mkdir /opt/oracle/mydump -p
create directory mydump as '/opt/oracle/mydump';
grant read on directory mydump to public;
grant write on directory mydump to public;
2.设置表空间为只读
alter TABLESPACE fixf read only;
3.执行一致性检查
exec sys.dbms_tts.transport_set_check('fixf',TRUE,TRUE);
select * from transport_set_violations;
4.导出表空间
expdp sys/12345 dumpfile=exp.dmp directory=mydump tablespaces=fixf transport_full_check=y logfile=fixf.log;
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": sys/******** AS SYSDBA dumpfile=exp.dmp directory=mydump transport_tablespaces=fixf transport_full_check=y logfile=fixf.log
Processing object type TRANSPORTABLE_EXPORT/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/STATISTICS/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/COMMENT
Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is:
/opt/oracle/mydump/exp.dmp
******************************************************************************
Datafiles required for transportable tablespace FIXF:
/opt/oracle/oradata/ORCL/datafile/o1_mf_fixf_hbzdq923_.dbf
Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at Thu Sep 17 10:46:12 2020 elapsed 0 00:01:27
5.创建到pdb的dblink
create public database link fixfpdb_link
connect to c##fixf IDENTIFIED by "12345"
using '192.168.5.129/fixfpdb';
6.传输数据文件
或者手工cp
BEGIN
dbms_file_transfer.put_file(source_directory_object => 'mydump'
,source_file_name => 'exp.dmp'
,destination_directory_object => 'mydump'
,destination_file_name => 'exp.dmp'
,destination_database => 'fixfpdb_link');
END;
/
7.目标库创建准备导入的表空间
create tablespace fixf;
8.导入数据
注意替换用户
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.修改原表空间为读写
alter tablespace fixf read write;