主题:Oracle导入导出之大字段从10g导出并导入11g
作者:基毛飞上天
场景:今天有个客户跟我说:怎么将Oracle 10g的LOB表导出来,并导入到Oracle 11g。为什么无法使用IMPDP工具导入呢?
思路:Oracle 10g 只有EXP/IMP工具。而EXP/IMP的工具都是一套的,所以,在Oracle 11g是不能使用IMPDP工具对EXP导出的DMP文件进行导入。
演示如下:
第一节:先在Oracle10g创建一个LOB表,然后通过EXP工具导出DMP文件。
第二节:把DMP文件传到Oracle11g的主机上,通过IMPDP工具测试导入。
第三节:Oracle11g通过IMP工具成功导入。
—————————- 第一节 —————————-
1. 创建LOB表
点击(此处)折叠或打开
-
SQL>conn hr/hr
-
Connected.
-
SQL>CREATETABLEMA_LOB_DUMP(nNUMBER,cCLOB)
-
lob(c)STOREASMA_SEG(
-
TABLESPACEusers
-
CHUNK 4096
-
NOCACHE LOGGING
-
STORAGE(MAXEXTENTS5));2 3 4 5 6
-
Tablecreated.
2. 向LOB表插入数据
点击(此处)折叠或打开
-
SQL>insertintoMA_LOB_DUMPvalues(1,\’12\’);
-
1rowcreated.
-
SQL>insertintoMA_LOB_DUMPvalues(1,\’123\’);
-
1rowcreated.
-
SQL>insertintoMA_LOB_DUMPvalues(2,\’2345\’);
-
1rowcreated.
-
SQL>insertintoMA_LOB_DUMPvalues(3,\’asdsada\’);
-
1rowcreated.
-
SQL>commit;
-
Commit complete.
3. 检查LOB表里的数据
点击(此处)折叠或打开
-
SQL>select*fromMA_LOB_DUMP;
-
N C
-
———- ————————
-
1 12
-
1 123
-
2 2345
-
3 asdsada
4. 查看LOB表的LOB名
点击(此处)折叠或打开
-
SQL>selectTABLE_NAME,SEGMENT_NAME,TABLESPACE_NAMEfromuser_lobswheretable_name=\’MA_LOB_DUMP\’;
-
TABLE_NAME SEGMENT_NAME TABLESPACE_NAME
-
—————– ————- ——————————
-
MA_LOB_DUMP MA_SEG USERS
5. exp工具导出LOB表
点击(此处)折叠或打开
-
[oracle@rhel-ORCLdump]$exphr/hrfile=/home/oracle/dump/ora10gCLOB.dmp tables=MA_LOB_DUMP
-
Export:Release10.2..1.0-ProductiononWed Jan 24 16:30:25 2018
-
Copyright(c)1982,2005,Oracle.Allrights reserved.
-
Connectedto:OracleDatabase10g Enterprise EditionRelease10.2..1.0-64bit Production
-
Withthe Partitioning,OLAPandDataMining options
-
Export doneinUS7ASCII charactersetandAL16UTF16 NCHAR characterset
-
server uses AL32UTF8 characterset(possible charset conversion)
-
Abouttoexport specified tables via Conventional Path…
-
..exportingtableMA_LOB_DUMP 4rowsexported
-
Export terminated successfully without warnings.
-
[oracle@rhel-ORCLdump]$ls
-
ora10gCLOB.dmp
-
[oracle@rhel-ORCLdump]$
-
—————————- 第二节 —————————-
-
6. 将dmp文件传到Oracle11g的主机上,创建目录对象,并对hr和oe用户解锁
-
点击(此处)折叠或打开
SQL>createdirectoryoradumpas\’/home/oracle/dump\’;
-
Directorycreated.
-
SQL>grantread,writeondirectoryoradumptopublic;
-
Grantsucceeded.
-
SQL>alteruseroeidentifiedby\”oe\”account unlock;
-
Useraltered.
-
SQL>alteruserhridentifiedby\”hr\”account unlock;
-
Useraltered.
-
7. 尝试使用impdp工具导入
-
点击(此处)折叠或打开
[oracle@rhel-ORCLdump]$impdp system/oracledirectory=oradump dumpfile=ora10gCLOB.dmp logfile=ora10gCLOB.logREMAP_SCHEMA=hr:oe REMAP_TABLESPACE=users:testlob ignore=y
-
Import:Release11.2..3.0-ProductiononWed Jan 24 16:41:41 2018
-
Copyright(c)1982,2011,Oracleand/orits affiliates.Allrights reserved.
-
UDI-28002:operation generated ORACLE error 28002
-
ORA-28002:thepasswordwill expire within 7 days
-
Connectedto:OracleDatabase11g Enterprise EditionRelease11.2..3.0-Production
-
Withthe Partitioning,OLAP,DataMiningandRealApplication Testing options
-
ORA-39001:invalid argumentvalue
-
ORA-39000:baddumpfilespecification
-
ORA-39143:dumpfile\”/home/oracle/dump/ora10gCLOB.dmp\”may be an original exportdumpfi
-
—————————- 第三节 —————————-
-
8. 使用imp工具导入
-
点击(此处)折叠或打开
[oracle@rhel-ORCLdump]$imp hr/hrfile=/home/oracle/dump/ora10gCLOB.dmplog=ora10gCLOB.logREMAP_SCHEMA=hr:oe REMAP_TABLESPACE=users:testlob ignore=y
-
LRM-00101:unknown parameter name\’REMAP_SCHEMA\’
-
IMP-00022:failedtoprocess parameters,type\’IMP HELP=Y\’forhelp
-
IMP-00000:Import terminated unsuccessfully
-
[oracle@rhel-ORCLdump]$imp hr/hrfile=/home/oracle/dump/ora10gCLOB.dmplog=ora10gCLOB.logfromuser=hr touser=oe tablespaces=testlob ignore=y
-
Import:Release11.2..3.0-ProductiononWed Jan 24 16:50:42 2018
-
Copyright(c)1982,2011,Oracleand/orits affiliates.Allrights reserved.
-
Connectedto:OracleDatabase11g Enterprise EditionRelease11.2..3.0-Production
-
Withthe Partitioning,OLAP,DataMiningandRealApplication Testing options
-
ExportfilecreatedbyEXPORT:V10.02.01 via conventional path
-
import doneinUS7ASCII charactersetandAL16UTF16 NCHAR characterset
-
import server uses AL32UTF8 characterset(possible charset conversion)
-
IMP-00007:must be a DBAtoimport objectstoanotheruser\’s account
-
IMP-00000: Import terminated unsuccessfully
-
[oracle@rhel-ORCL dump]$imp system/oracle file=/home/oracle/dump/ora10gCLOB.dmp log=ora10gCLOB.log fromuser=hr touser=oe tablespaces=testlob ignore=y
-
Import: Release 11.2.0.3.0 – Production on Wed Jan 24 16:51:16 2018
-
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
-
IMP-00058: ORACLE error 28002 encountered
-
ORA-28002: the password will expire within 7 days
-
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
Export file created by EXPORT:V10.02.01 via conventional path
-
Warning: the objects were exported by HR, not by you
-
import done in US7ASCII character set and AL16UTF16 NCHAR character set
-
import server uses AL32UTF8 character set (possible charset conversion)
-
. importing HR\’s objectsintoOE
-
..importingtable\”MA_LOB_DUMP\”4rowsimported
-
Import terminated successfullywithwarnings.
-
9. Oracle11g OE用户检查数据
-
点击(此处)折叠或打开
SQL>conn oe/oe
-
Connected.
-
SQL>select*fromMA_LOB_DUMP;
-
N C
-
——— ———-
-
1 12
-
1 123
-
2 2345
-
3 asdsada
-
10. Oracle11g检查LOB段的表空间
-
点击(此处)折叠或打开
— 用户的默认表空间
-
SQL>selectUSERNAME,DEFAULT_TABLESPACEfromuser_users;
-
USERNAME DEFAULT_TABLESPACE
-
—————————— ——————————
-
OE TESTLOB
-
— TABLE段的默认表空间是USERS
-
SQL>selectTABLE_NAME,TABLESPACE_NAMEfromuser_tableswheretable_name=\’MA_LOB_DUMP\’;
-
TABLE_NAME TABLESPACE_NAME
-
—————————— ——————————
-
MA_LOB_DUMP USERS
-
— 移动TABLE到表空间TESTLOB
-
SQL>altertableMA_LOB_DUMP movetablespaceTESTLOB;
-
Tablealtered.
-
SQL>selectTABLE_NAME,TABLESPACE_NAMEfromuser_tableswheretable_name=\’MA_LOB_DUMP\’;
-
TABLE_NAME TABLESPACE_NAME
-
—————————— ——————————
-
MA_LOB_DUMP TESTLOB
-
— LOB段的默认表空间是USERS
-
SQL>selectTABLE_NAME,TABLESPACE_NAME,SECUREFILEfromuser_lobswheretable_name=\’MA_LOB_DUMP\’;
-
TABLE_NAME TABLESPACE_NAME SEC
-
————- —————– —————————— —
-
MA_LOB_DUMP USERS NO
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31092650/viewspace-2155768/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31092650/viewspace-2155768/