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 > CREATE TABLE MA_LOB_DUMP ( n NUMBER , c CLOB )

  4.       lob ( c ) STORE AS MA_SEG (

  5.      TABLESPACE users

  6.       CHUNK 4096

  7.       NOCACHE LOGGING

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


  9. Table created .

2. 向LOB表插入数据


点击( 此处 )折叠或打开

  1. SQL > insert into MA_LOB_DUMP values ( 1 , '12' ) ;


  2. 1 row created .


  3. SQL > insert into MA_LOB_DUMP values ( 1 , '123' ) ;


  4. 1 row created .


  5. SQL > insert into MA_LOB_DUMP values ( 2 , '2345' ) ;


  6. 1 row created .


  7. SQL > insert into MA_LOB_DUMP values ( 3 , 'asdsada' ) ;


  8. 1 row created .


  9. SQL > commit ;


  10. Commit complete .

3. 检查LOB表里的数据


点击( 此处 )折叠或打开

  1. SQL > select * from MA_LOB_DUMP ;


  2.      N                        C

  3. ----------         ----------------- ------ -

  4.      1                      12

  5.      1                      123

  6.      2                      2345

  7.      3                      asdsada


4. 查看LOB表的LOB名


点击( 此处 )折叠或打开

  1. SQL > select TABLE_NAME , SEGMENT_NAME , TABLESPACE_NAME from user_lobs where table_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 - ORCL dump ] $ exp hr / hr file = / home / oracle / dump / ora10gCLOB . dmp tables = MA_LOB_DUMP


  2. Export : Release 10 . 2 . . 1 . 0 - Production on Wed Jan 24 16 : 30 : 25 2018


  3. Copyright ( c ) 1982 , 2005 , Oracle . All rights reserved .



  4. Connected to : Oracle Database 10g Enterprise Edition Release 10 . 2 . . 1 . 0 - 64bit Production

  5. With the Partitioning , OLAP and Data Mining options

  6. Export done in US7ASCII character set and AL16UTF16 NCHAR character set

  7. server uses AL32UTF8 character set ( possible charset conversion )


  8. About to export specified tables via Conventional Path . . .

  9. . . exporting table MA_LOB_DUMP          4 rows exported

  10. Export terminated successfully without warnings .

  11. [ oracle @ rhel - ORCL dump ] $ ls

  12. ora10gCLOB . dmp

  13. [ oracle @ rhel - ORCL dump ] $


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




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


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


    1. SQL > create directory oradump as '/home/oracle/dump' ;


    2. Directory created .


    3. SQL > grant read , write on directory oradump to public ;


    4. Grant succeeded .


    5. SQL > alter user oe identified by "oe" account unlock ;


    6. User altered .


    7. SQL > alter user hr identified by "hr" account unlock ;


    8. User altered .


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



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

    1. [ oracle @ rhel - ORCL dump ] $ impdp system / oracle directory = oradump dumpfile = ora10gCLOB . dmp logfile = ora10gCLOB . log REMAP_SCHEMA = hr : oe REMAP_TABLESPACE = users : testlob ignore = y


    2. Import : Release 11 . 2 . . 3 . 0 - Production on Wed Jan 24 16 : 41 : 41 2018


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


    4. UDI - 28002 : operation generated ORACLE error 28002

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


    6. Connected to : Oracle Database 11g Enterprise Edition Release 11 . 2 . . 3 . 0 - Production

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

    8. ORA - 39001 : invalid argument value

    9. ORA - 39000 : bad dump file specification

    10. ORA - 39143 : dump file "/home/oracle/dump/ora10gCLOB.dmp" may be an original export dump fi



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


  1. 8. 使用imp工具导入



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

    1. [ oracle @ rhel - ORCL dump ] $ imp hr / hr file = / home / oracle / dump / ora10gCLOB . dmp log = ora10gCLOB . log REMAP_SCHEMA = hr : oe REMAP_TABLESPACE = users : testlob ignore = y

    2. LRM - 00101 : unknown parameter name 'REMAP_SCHEMA'


    3. IMP - 00022 : failed to process parameters , type 'IMP HELP=Y' for help

    4. IMP - 00000 : Import terminated unsuccessfully



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


    6. Import : Release 11 . 2 . . 3 . 0 - Production on Wed Jan 24 16 : 50 : 42 2018


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



    8. Connected to : Oracle Database 11g Enterprise Edition Release 11 . 2 . . 3 . 0 - Production

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


    10. Export file created by EXPORT : V10 . 02 . 01 via conventional path

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

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

    13. IMP - 00007 : must be a DBA to import objects to another user '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 objects into OE

    27. . . importing table "MA_LOB_DUMP" 4 rows imported

    28. Import terminated successfully with warnings .


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


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

    1. SQL > conn oe / oe

    2. Connected .

    3. SQL > select * from MA_LOB_DUMP ;


    4.      N         C

    5. ---------  ----------

    6.      1         12

    7.      1         123

    8.      2         2345

    9.      3         asdsada


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



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



    1. -- 用户的默认表空间

    2. SQL > select USERNAME , DEFAULT_TABLESPACE from user_users ;


    3. USERNAME                          DEFAULT_TABLESPACE

    4. ------------------------------ ------------------------------

    5. OE                                 TESTLOB


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


    7. SQL > select TABLE_NAME , TABLESPACE_NAME from user_tables where table_name = 'MA_LOB_DUMP' ;


    8. TABLE_NAME                          TABLESPACE_NAME

    9. ------------------------------ ------------------------------

    10. MA_LOB_DUMP                            USERS



    11. -- 移动TABLE到表空间TESTLOB

    12. SQL > alter table MA_LOB_DUMP move tablespace TESTLOB ;


    13. Table altered .


    14. SQL > select TABLE_NAME , TABLESPACE_NAME from user_tables where table_name = 'MA_LOB_DUMP' ;


    15. TABLE_NAME                         TABLESPACE_NAME

    16. ------------------------------ ------------------------------

    17. MA_LOB_DUMP                           TESTLOB



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

    19. SQL > select TABLE_NAME , TABLESPACE_NAME , SECUREFILE from user_lobs where table_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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值