环境介绍
|
项目 |
源端 |
目标端 |
|
操作系统 |
Windows Server 2008R2 64bit |
Oracle Linux 7.8 64bit |
|
数据库版本 |
Oracle 11.2.0.1 |
Oracle 19c |
|
存储系统 |
文件系统 |
ASM |
|
字节序 |
little |
little |
create tablespace mytbs1 datafile 'C:\oradata\mytbs1.dbf' size 500M autoextend on maxsize 30G;
create tablespace mytbs2 datafile 'C:\oradata\mytbs2.dbf' size 500M autoextend on maxsize 30G;
create user testuser identified by "testuser" default tablespace mytbs1 temporary tablespace temp;
grant unlimited tablespace to testuser;
grant resource, connect to testuser;
create table testuser.tb1(id number, name varchar2(100)) tablespace mytbs1;
alter table testuser.tb1 add constraint pk_tb1 primary key(id) using index TABLESPACE mytbs2;
insert into testuser.tb1 select object_id, object_name from all_objects;
检查字符集:
SELECT * FROM NLS_DATABASE_PARAMETERS T WHERE T.PARAMETER LIKE '%CHARACTERSET';
检查DBTIMEZONE
SELECT version FROM v$timezone_file;
在这次测试中,windows主机的version为11,linux主机为32
因为这次测试的时候,目标端是19c,所以这个没有关系。Timezone不同的问题可能导致导入时出现ORA-39322错误,在11.2.0.4版本中已经解决
EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK('mytbs1', TRUE);
EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK('mytbs2', TRUE);
SELECT * FROM TRANSPORT_SET_VIOLATIONS;
这个例子当中,我们需要处理两个表空间。
将源端表空间设置为只读:
alter tablespace mytbs1 read only;
alter tablespace mytbs2 read only;
创建目录对象
create directory mydump_dir as 'C:\dumpfile';
导出元数据
expdp \"/ as sysdba\" dumpfile=tts_test.dmp directory=mydump_dir transport_tablespaces=mytbs1,mytbs2 transport_full_check=y logfile=tts_test.dmp.log
将数据文件从源端拷贝至目标端
create user testuser identified by "testuser" default tablespace users temporary tablespace temp;
grant unlimited tablespace to testuser;
grant resource, connect to testuser;
不预先创建好用户的话,会出错
在ASMCMD下执行:
cp /tmp/MYTBS1.DBF +data/orcl/datafile/MYTBS1.DBF
cp /tmp/MYTBS2.DBF +data/orcl/datafile/MYTBS2.DBF
impdp \' sys/sys as sysdba\' directory=mydump_dir dumpfile=TEST_TTS.DMP transport_datafiles=+data/orcl/datafile/MYTBS1.DBF,+data/orcl/datafile/MYTBS2.DBF logfile=impdp_tts.log
注意,windows下使用expdp导出时,文件名是大写, linux下面大小写是敏感的
导入完成:
alter tablespace mytbs1 read write;
alter tablespace mytbs2 read write;
alter user testuser default tablespace mytbs1;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8520577/viewspace-2885057/ ,如需转载,请注明出处,否则将追究法律责任。