Oracle 資料移轉(從Oracle11G高版本遷移到Oracle10G低版本),oracle11goracle10g

來源:互聯網
上載者:User

Oracle 資料移轉(從Oracle11G高版本遷移到Oracle10G低版本),oracle11goracle10g


1,資料庫狀況
    生產環境是11G,linux系統,測試環境是10G,windows系統,需要從生產環境匯出一個使用者下所有的資料,匯入測試環境中。
    因為資料量比較小,準備採用EXP和IMP工具來做。
    


2,在生產環境上匯出使用者資料
    命令:
       exp \'system/syspl as sysdba\' owner=PLAS buffer=10240000 FILE=/tmp/PLAS_20141113.DMP

   執行過程:
[oracle@localhost ~]$  exp \'system/syspl as sysdba\' owner=PLAS buffer=10240000 FILE=/tmp/PLAS_20141113.DMP


Export: Release 11.2.0.1.0 - Production on Thu Nov 13 19:32:52 2014


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




Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set


About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user PLAS 
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user PLAS 
............
 . exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.'



3,在測試環境匯入資料

3.1,先備份測試環境的資料
    命令:
   exp 'sys/tesyspd@MP_EX as sysdba' owner=PLAS buffer=10240000 FILE="F:\TEST-PLAS_EX-1114.DMP"
  執行過程:
C:\Documents and Settings\Administrator>exp 'sys/tesyspd@MP_EX as sysdba' owner=PLAS buffer=10240000 FILE="F:\TEST-PLAS_EX-1114.DMP"



Export: Release 10.2.0.1.0 - Production on 星期四 11月 13 20:25:26 2014



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








串連到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engin
e options
已匯出 ZHS16GBK 字元集和 AL16UTF16 NCHAR 字元集




即將匯出指定的使用者...
. 正在匯出 pre-schema 過程對象和操作
. 正在匯出使用者 PLAS 的外部函數庫名
. 匯出 PUBLIC 類型同義字
. 正在匯出專用類型同義字
. 正在匯出使用者 PLAS 的物件類型定義
.........
. . 正在匯出表                        S_MIDORG匯出了         738 行
. . 正在匯出表                      S_MIDUSERS匯出了        2746 行
. . 正在匯出表                     S_ROOM_COMP匯出了           3 行
. . 正在匯出表                 TOAD_PLAN_TABLE匯出了           0 行
. . 正在匯出表                      T_COREMAIL匯出了          82 行
. 正在匯出同義字
. 正在匯出視圖
. 正在匯出預存程序
. 正在匯出運算子
. 正在匯出參考完整性約束條件
. 正在匯出觸發器
. 正在匯出索引類型
. 正在匯出位元影像, 功能性索引和可擴充索引
. 正在匯出後期表活動
. 正在匯出實體化視圖
. 正在匯出快照日誌
. 正在匯出作業隊列
. 正在匯出重新整理組和子組
. 正在匯出維
. 正在匯出 post-schema 過程對象和操作
. 正在匯出統計資訊
成功終止匯出, 沒有出現警告。



3.2,匯入資料
C:\Documents and Settings\Administrator>IMP 'sys/tesyspd@MP_TEST as sysdba' BUFFER=10240000 FILE=F:\ORACLE_EXP\MP_EX-PLAS-20141114.DMP FROMUSER=PLAS TOUSER=PLAS 
......
即將啟用約束條件...
成功終止匯入, 但出現警告。


C:\Documents and Settings\Administrator>



4,執行過程中錯誤記錄

4.1,linux匯出報錯
[oracle@localhost ~]$ exp "system/syspl@powerdes" owner=PLAS buffer=10240000 FILE=/tmp/PLAS_20141113.DMP




Export: Release 11.2.0.1.0 - Production on Thu Nov 13 19:25:47 2014




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


EXP-00056: ORACLE error 28009 encountered
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Username: 
Password: 


EXP-00056: ORACLE error 1017 encountered
ORA-01017: invalid username/password; logon denied
EXP-00005: all allowable logon attempts failed
EXP-00000: Export terminated unsuccessfully
[oracle@localhost ~]$ 

匯入報錯,是因為 linux /unix 逸出字元,需要在上面加上轉義符號,比如\',修改成如下命令即可:
exp \'system/syspl as sysdba\' owner=PLAS buffer=10240000 FILE=/tmp/PLAS_20141113.DMP




4.2,Windows下匯入報錯


C:\Documents and Settings\Administrator> imp 'sys/tesyspd@MP_TEST as sysdba' BUFFER=10240000 FILE=D:\oracle\imp\PLAS_20141113.DMP FROMUSER=PLAS TOUSER=PLAS


Import: Release 10.2.0.1.0 - Production on 星期四 11月 13 20:53:02 2014

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

串連到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engin
e options

IMP-00010: 不是有效匯出檔案, 頭部驗證失敗
IMP-00000: 未成功終止匯入


解決辦法: 參考文章http://www.2cto.com/database/201401/272732.html
通過工具將dmp檔案頭部的“11.20.00“ 改為”10.20.10“即可。


4.3,IMP表已經存在的問題
......
IMP-00015: 由於對象已存在, 下列語句失敗:
 "CREATE PACKAGE             "sss" sss is"
 ""
 "  -- Author  : ADMINISTRATOR"
 "  -- Created : 2012/3/20 16:14:58"
 "  -- Purpose : sssss"
 ......
IMP報已經存在的表不能CREATE的問題,通過PLSQL的介面可以在IMP之前刪除使用者下所以對象,比如刪除表的方式為:選擇Users->PLAS->Objects->Tables,選中所有表,右鍵點擊Drop操作就會刪除掉目前使用者PLAS下所有表。之後再執行IMP命令。

----------------------------------------------------------------------------------------------------------------
<著作權,文章允許轉載,但必須以連結方式註明源地址,否則追究法律責任!>
原部落格地址:  http://blog.itpub.net/26230597/viewspace-1333180/
原作者:黃杉 (mchdba)
----------------------------------------------------------------------------------------------------------------

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.