AI智能
改变未来

Oracle导入导出之大字段从10g导出并导入11g

主题: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表

点击(此处)折叠或打开

  1. SQL>conn hr/hr

  2. Connected.

  3. SQL>CREATETABLEMA_LOB_DUMP(nNUMBER,cCLOB)

  4.       lob(c)STOREASMA_SEG(

  5.     TABLESPACEusers

  6.       CHUNK 4096

  7.       NOCACHE LOGGING

  8.       STORAGE(MAXEXTENTS5));2    3    4    5    6

  9. Tablecreated.

2. 向LOB表插入数据

点击(此处)折叠或打开

  1. SQL>insertintoMA_LOB_DUMPvalues(1,\’12\’);

  2. 1rowcreated.

  3. SQL>insertintoMA_LOB_DUMPvalues(1,\’123\’);

  4. 1rowcreated.

  5. SQL>insertintoMA_LOB_DUMPvalues(2,\’2345\’);

  6. 1rowcreated.

  7. SQL>insertintoMA_LOB_DUMPvalues(3,\’asdsada\’);

  8. 1rowcreated.

  9. SQL>commit;

  10. Commit complete.

3. 检查LOB表里的数据

点击(此处)折叠或打开

  1. SQL>select*fromMA_LOB_DUMP;

  2.      N                       C

  3. ———-        ————————

  4.      1                      12

  5.      1                      123

  6.      2                      2345

  7.      3                      asdsada

4. 查看LOB表的LOB名

点击(此处)折叠或打开

  1. SQL>selectTABLE_NAME,SEGMENT_NAME,TABLESPACE_NAMEfromuser_lobswheretable_name=\’MA_LOB_DUMP\’;

  2. TABLE_NAME           SEGMENT_NAME     TABLESPACE_NAME

  3. —————–  ————-  ——————————

  4. MA_LOB_DUMP               MA_SEG             USERS

5. exp工具导出LOB表

点击(此处)折叠或打开

  1. [oracle@rhel-ORCLdump]$exphr/hrfile=/home/oracle/dump/ora10gCLOB.dmp tables=MA_LOB_DUMP

  2. Export:Release10.2..1.0-ProductiononWed Jan 24 16:30:25 2018

  3. Copyright(c)1982,2005,Oracle.Allrights reserved.

  4. Connectedto:OracleDatabase10g Enterprise EditionRelease10.2..1.0-64bit Production

  5. Withthe Partitioning,OLAPandDataMining options

  6. Export doneinUS7ASCII charactersetandAL16UTF16 NCHAR characterset

  7. server uses AL32UTF8 characterset(possible charset conversion)

  8. Abouttoexport specified tables via Conventional Path…

  9. ..exportingtableMA_LOB_DUMP          4rowsexported

  10. Export terminated successfully without warnings.

  11. [oracle@rhel-ORCLdump]$ls

  12. ora10gCLOB.dmp

  13. [oracle@rhel-ORCLdump]$

  1. —————————-   第二节   —————————-

  1. 6. 将dmp文件传到Oracle11g的主机上,创建目录对象,并对hr和oe用户解锁

  1. 点击(此处)折叠或打开

    SQL>createdirectoryoradumpas\’/home/oracle/dump\’;

  2. Directorycreated.

  3. SQL>grantread,writeondirectoryoradumptopublic;

  4. Grantsucceeded.

  5. SQL>alteruseroeidentifiedby\”oe\”account unlock;

  6. Useraltered.

  7. SQL>alteruserhridentifiedby\”hr\”account unlock;

  8. Useraltered.

  1. 7. 尝试使用impdp工具导入

  1. 点击(此处)折叠或打开

    [oracle@rhel-ORCLdump]$impdp system/oracledirectory=oradump dumpfile=ora10gCLOB.dmp logfile=ora10gCLOB.logREMAP_SCHEMA=hr:oe REMAP_TABLESPACE=users:testlob ignore=y

  2. Import:Release11.2..3.0-ProductiononWed Jan 24 16:41:41 2018

  3. Copyright(c)1982,2011,Oracleand/orits affiliates.Allrights reserved.

  4. UDI-28002:operation generated ORACLE error 28002

  5. ORA-28002:thepasswordwill expire within 7 days

  6. Connectedto:OracleDatabase11g Enterprise EditionRelease11.2..3.0-Production

  7. Withthe Partitioning,OLAP,DataMiningandRealApplication Testing options

  8. ORA-39001:invalid argumentvalue

  9. ORA-39000:baddumpfilespecification

  10. ORA-39143:dumpfile\”/home/oracle/dump/ora10gCLOB.dmp\”may be an original exportdumpfi

  1. —————————-   第三节   —————————-


  1. 8. 使用imp工具导入

  1. 点击(此处)折叠或打开

    [oracle@rhel-ORCLdump]$imp hr/hrfile=/home/oracle/dump/ora10gCLOB.dmplog=ora10gCLOB.logREMAP_SCHEMA=hr:oe REMAP_TABLESPACE=users:testlob ignore=y

  2. LRM-00101:unknown parameter name\’REMAP_SCHEMA\’

  3. IMP-00022:failedtoprocess parameters,type\’IMP HELP=Y\’forhelp

  4. IMP-00000:Import terminated unsuccessfully

  5. [oracle@rhel-ORCLdump]$imp hr/hrfile=/home/oracle/dump/ora10gCLOB.dmplog=ora10gCLOB.logfromuser=hr touser=oe tablespaces=testlob ignore=y

  6. Import:Release11.2..3.0-ProductiononWed Jan 24 16:50:42 2018

  7. Copyright(c)1982,2011,Oracleand/orits affiliates.Allrights reserved.

  8. Connectedto:OracleDatabase11g Enterprise EditionRelease11.2..3.0-Production

  9. Withthe Partitioning,OLAP,DataMiningandRealApplication Testing options

  10. ExportfilecreatedbyEXPORT:V10.02.01 via conventional path

  11. import doneinUS7ASCII charactersetandAL16UTF16 NCHAR characterset

  12. import server uses AL32UTF8 characterset(possible charset conversion)

  13. IMP-00007:must be a DBAtoimport objectstoanotheruser\’s account

  14. IMP-00000: Import terminated unsuccessfully

  15. [oracle@rhel-ORCL dump]$imp system/oracle file=/home/oracle/dump/ora10gCLOB.dmp log=ora10gCLOB.log fromuser=hr touser=oe tablespaces=testlob ignore=y

  16. Import: Release 11.2.0.3.0 – Production on Wed Jan 24 16:51:16 2018

  17. Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

  18. IMP-00058: ORACLE error 28002 encountered

  19. ORA-28002: the password will expire within 7 days

  20. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – Production

  21. With the Partitioning, OLAP, Data Mining and Real Application Testing options

  22. Export file created by EXPORT:V10.02.01 via conventional path

  23. Warning: the objects were exported by HR, not by you

  24. import done in US7ASCII character set and AL16UTF16 NCHAR character set

  25. import server uses AL32UTF8 character set (possible charset conversion)

  26. . importing HR\’s objectsintoOE

  27. ..importingtable\”MA_LOB_DUMP\”4rowsimported

  28. Import terminated successfullywithwarnings.

  1. 9.  Oracle11g OE用户检查数据

  1. 点击(此处)折叠或打开

    SQL>conn oe/oe

  2. Connected.

  3. SQL>select*fromMA_LOB_DUMP;

  4.      N         C

  5. ———  ———-

  6.      1         12

  7.      1         123

  8.      2         2345

  9.      3         asdsada

  1. 10. Oracle11g检查LOB段的表空间

  1. 点击(此处)折叠或打开

    — 用户的默认表空间

  2. SQL>selectUSERNAME,DEFAULT_TABLESPACEfromuser_users;

  3. USERNAME                          DEFAULT_TABLESPACE

  4. —————————— ——————————

  5. OE                                 TESTLOB

  6. — TABLE段的默认表空间是USERS

  7. SQL>selectTABLE_NAME,TABLESPACE_NAMEfromuser_tableswheretable_name=\’MA_LOB_DUMP\’;

  8. TABLE_NAME                          TABLESPACE_NAME

  9. —————————— ——————————

  10. MA_LOB_DUMP                            USERS

  11. — 移动TABLE到表空间TESTLOB

  12. SQL>altertableMA_LOB_DUMP movetablespaceTESTLOB;

  13. Tablealtered.

  14. SQL>selectTABLE_NAME,TABLESPACE_NAMEfromuser_tableswheretable_name=\’MA_LOB_DUMP\’;

  15. TABLE_NAME                         TABLESPACE_NAME

  16. —————————— ——————————

  17. MA_LOB_DUMP                           TESTLOB

  18. — LOB段的默认表空间是USERS

  19. SQL>selectTABLE_NAME,TABLESPACE_NAME,SECUREFILEfromuser_lobswheretable_name=\’MA_LOB_DUMP\’;

  20. TABLE_NAME      TABLESPACE_NAME         SEC

  21. ————-  —————– —————————— —

  22. MA_LOB_DUMP      USERS                   NO

  • 来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31092650/viewspace-2155768/,如需转载,请注明出处,否则将追究法律责任。

    转载于:http://blog.itpub.net/31092650/viewspace-2155768/

    赞(0) 打赏
    未经允许不得转载:爱站程序员基地 » Oracle导入导出之大字段从10g导出并导入11g