1. 程式人生 > >ORACLE 12C 匯入9i匯出的含有多個使用者的dmp檔案

ORACLE 12C 匯入9i匯出的含有多個使用者的dmp檔案

從EBS 11i 中用system使用者 exp了幾個表,以 user.table
的形式匯出,在12C中進行恢復的時候其中fromuser使用者選擇了system,結果發現沒有匯入成功資料,經過一番折騰發現fromuser必須是表的屬主使用者。記錄下過程:

在9i資料庫遇到的匯出問題

#在沒有賦予特殊許可權的情況下,只能匯出自己建立的表
$ exp userid=apps/<密碼> tables=HR_ALL_ORGANIZATION_UNITS,FND_USER file=/redolog/sdprd/SDYD_all.dmp log=/redolog/s>

Export: Release 9.2
.0.6.0 - Production on Tue Mar 15 16:42:15 2016 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.6.0 - Production Export done in
ZHS16GBK character set and UTF8 NCHAR character set About to export specified tables via Conventional Path ... EXP-00011: APPS.HR_ALL_ORGANIZATION_UNITS does not exist EXP-00011: APPS.FND_USER does not exist Export terminated successfully with warnings. #加上schema也不可以,提示許可權不夠 $ exp userid=apps/<密碼> tables=HR.HR_ALL_ORGANIZATION_UNITS,APPLSYS.FND_USER file=/redolog/sdprd/SDYD_all.dmp log> Export: Release 9.2
.0.6.0 - Production on Tue Mar 15 16:42:26 2016 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.6.0 - Production Export done in ZHS16GBK character set and UTF8 NCHAR character set About to export specified tables via Conventional Path ... EXP-00009: no privilege to export HR's table HR_ALL_ORGANIZATION_UNITS EXP-00009: no privilege to export APPLSYS's table FND_USER Export terminated successfully with warnings. #賦予 匯出所有資料庫的許可權,就可以了 $ sqlplus "/ as sysdba" SQL*Plus: Release 9.2.0.6.0 - Production on Tue Mar 15 16:44:03 2016 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.6.0 - Production SQL> grant exp_full_database to apps; Grant succeeded. SQL> commit 2 ; Commit complete. SQL> exit Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.6.0 - Production #加上schema後進行匯出 $ exp userid=apps/<密碼> tables=HR.HR_ALL_ORGANIZATION_UNITS,APPLSYS.FND_USER file=/redolog/sdprd/SDYD_all.dmp log> Export: Release 9.2.0.6.0 - Production on Tue Mar 15 16:44:50 2016 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.6.0 - Production Export done in ZHS16GBK character set and UTF8 NCHAR character set About to export specified tables via Conventional Path ... Current user changed to HR . . exporting table HR_ALL_ORGANIZATION_UNITS 4444 rows exported Current user changed to APPLSYS . . exporting table FND_USER 3335 rows exported Export terminated successfully without warnings. $ #移除許可權 SQL> revoke exp_full_database from apps;

在目標資料庫進行恢復,遇到匯入問題


C:\app\oracle\product\12.1.0\dbhome_1\BIN>sqlplus "/ as sysdba"

SQL*Plus: Release 12.1.0.2.0 Production on 星期二 315 18:18:34 2016

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


連線到:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
#開啟所有PDB
[email protected]> alter pluggable database all open;

插接式資料庫已變更。

#切換到一個pdb
[email protected]> alter session set container = pyang1
  2  ;

會話已更改。

#檢視當前登入身份
[email protected]> show user
USER 為 "SYS"
[email protected]> show con_id

CON_ID
------------------------------
3
[email protected]> show con_name

CON_NAME
------------------------------
PYANG1


#建立schema使用者

[email protected]> create user test identified by test default tablespace users;

使用者已建立。

[email protected]> grant connect,resource to test;

授權成功。

[email protected]> commit;

提交完成。


[email protected]> exit
從 Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options 斷開

#進行匯入

C:\app\oracle\product\12.1.0\dbhome_1\BIN>imp test/[email protected]:1521/pyang1 file=c:\SDYD_test.dmp FROMUSER=system touser=test

Import: Release 12.1.0.2.0 - Production on 星期二 315 18:30:15 2016

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


連線到: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

經由常規路徑由 EXPORT:V09.02.00 建立的匯出檔案
IMP-00013: 只有 DBA 才能匯入由其他 DBA 匯出的檔案
IMP-00000: 未成功終止匯入

#許可權不夠,再進行賦權
C:\app\oracle\product\12.1.0\dbhome_1\BIN>sqlplus  sys/<密碼>@localhost:1521/pyang1 as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on 星期二 315 18:30:35 2016

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


連線到:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

[email protected]> grant dba to test;

授權成功。

[email protected]> commit;

提交完成。

[email protected]> exit
從 Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options 斷開

#再進行匯入
C:\app\oracle\product\12.1.0\dbhome_1\BIN>imp test/[email protected]:1521/pyang1 file=c:\SDYD_test.dmp FROMUSER=system touser=test

Import: Release 12.1.0.2.0 - Production on 星期二 315 18:31:26 2016

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


連線到: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

經由常規路徑由 EXPORT:V09.02.00 建立的匯出檔案

警告: 這些物件由 SYSTEM 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
匯出伺服器使用 UTF8 NCHAR 字符集 (可能的 ncharset 轉換)
成功終止匯入, 沒有出現警告。

#加入指定表名
C:\app\oracle\product\12.1.0\dbhome_1\BIN>imp test/[email protected]:1521/pyang1 file=c:\SDYD_test.dmp FROMUSER=system touser=test tables=(HR_ALL_ORGANIZATION_UNITS)

Import: Release 12.1.0.2.0 - Production on 星期二 315 18:33:34 2016

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


連線到: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

經由常規路徑由 EXPORT:V09.02.00 建立的匯出檔案

警告: 這些物件由 SYSTEM 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
匯出伺服器使用 UTF8 NCHAR 字符集 (可能的 ncharset 轉換)
IMP-00033: 警告: 在匯出檔案中未找到表 "HR_ALL_ORGANIZATION_UNITS"
成功終止匯入, 但出現警告。

#表名指定使用者
C:\app\oracle\product\12.1.0\dbhome_1\BIN>imp test/[email protected]:1521/pyang1 file=c:\SDYD_test.dmp FROMUSER=system touser=test tables=(HR.HR_ALL_ORGANIZATION_UNITS)

Import: Release 12.1.0.2.0 - Production on 星期二 315 18:34:01 2016

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


連線到: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

經由常規路徑由 EXPORT:V09.02.00 建立的匯出檔案

警告: 這些物件由 SYSTEM 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
匯出伺服器使用 UTF8 NCHAR 字符集 (可能的 ncharset 轉換)
IMP-00029: 無法使用所有者 (HR.HR_ALL_ORGANIZATION_UNITS) 限定表名, 請使用 FROMUSER 引數
IMP-00000: 未成功終止匯入

#更改fromuser 使用者
C:\app\oracle\product\12.1.0\dbhome_1\BIN>imp test/[email protected]:1521/pyang1 file=c:\SDYD_test.dmp FROMUSER=HR touser=test tables=(HR_ALL_ORGANIZATION_UNITS)

Import: Release 12.1.0.2.0 - Production on 星期二 315 18:34:34 2016

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


連線到: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

經由常規路徑由 EXPORT:V09.02.00 建立的匯出檔案

警告: 這些物件由 SYSTEM 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
匯出伺服器使用 UTF8 NCHAR 字符集 (可能的 ncharset 轉換)
. 正在將 HR 的物件匯入到 TEST
. . 正在匯入表     "HR_ALL_ORGANIZATION_UNITS"匯入了        4507 行
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT ALTER ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT DELETE ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT INDEX ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT INSERT ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT SELECT ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT UPDATE ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT REFERENCES ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT ON COMMIT REFRESH ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT"
 " OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT QUERY REWRITE ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPT"
 "ION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT DEBUG ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 1917, 以下語句失敗:
 "GRANT FLASHBACK ON "HR_ALL_ORGANIZATION_UNITS" TO "APPS" WITH GRANT OPTION"
IMP-00003: 遇到 ORACLE 錯誤 1917
ORA-01917: 使用者或角色 'APPS' 不存在
IMP-00017: 由於 ORACLE 錯誤 942, 以下語句失敗:
 "ALTER TABLE "HR_ALL_ORGANIZATION_UNITS" ADD CONSTRAINT "HR_ORGANIZATION_UNI"
 "TS_FK3" FOREIGN KEY ("LOCATION_ID") REFERENCES "HR_LOCATIONS_ALL" ("LOCATIO"
 "N_ID") ENABLE NOVALIDATE"
IMP-00003: 遇到 ORACLE 錯誤 942
ORA-00942: 表或檢視不存在
IMP-00017: 由於 ORACLE 錯誤 942, 以下語句失敗:
 "ALTER TABLE "HR_ALL_ORGANIZATION_UNITS" ADD CONSTRAINT "HR_ORGANIZATION_UNI"
 "TS_FK2" FOREIGN KEY ("COST_ALLOCATION_KEYFLEX_ID") REFERENCES "PAY_COST_ALL"
 "OCATION_KEYFLEX" ("COST_ALLOCATION_KEYFLEX_ID") ENABLE NOVALIDATE"
IMP-00003: 遇到 ORACLE 錯誤 942
ORA-00942: 表或檢視不存在
即將啟用約束條件...
成功終止匯入, 但出現警告。

C:\app\oracle\product\12.1.0\dbhome_1\BIN>

#   看下幫助
C:\app\oracle\product\12.1.0\dbhome_1\BIN>imp help=y

Import: Release 12.1.0.2.0 - Production on 星期二 315 19:02:59 2016

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



通過輸入 IMP 命令和您的使用者名稱/口令, 匯入
操作將提示您輸入引數:

     例如: IMP SCOTT/TIGER

或者, 可以通過輸入 IMP 命令和各種引數來控制匯入
的執行方式。要指定引數, 您可以使用關鍵字:

     格式:  IMP KEYWORD=value 或 KEYWORD=(value1,value2,...,valueN)
     例如: IMP SCOTT/TIGER IGNORE=Y TABLES=(EMP,DEPT) FULL=N
               或 TABLES=(T1:P1,T1:P2), 如果 T1 是分割槽表

USERID 必須是命令列中的第一個引數。

關鍵字   說明 (預設值)        關鍵字      說明 (預設值)
--------------------------------------------------------------------------
USERID   使用者名稱/口令           FULL       匯入整個檔案 (N)
BUFFER   資料緩衝區大小        FROMUSER    所有者使用者名稱列表
FILE     輸入檔案 (EXPDAT.DMP)  TOUSER     使用者名稱列表
SHOW     只列出檔案內容 (N)     TABLES      表名列表
IGNORE   忽略建立錯誤 (N)    RECORDLENGTH  IO 記錄的長度
GRANTS   匯入許可權 (Y)          INCTYPE     增量匯入型別
INDEXES   匯入索引 (Y)         COMMIT       提交陣列插入 (N)
ROWS     匯入資料行 (Y)        PARFILE      引數檔名
LOG     螢幕輸出的日誌檔案    CONSTRAINTS    匯入限制 (Y)
DESTROY                覆蓋表空間資料檔案 (N)
INDEXFILE              將表/索引資訊寫入指定的檔案
SKIP_UNUSABLE_INDEXES  跳過不可用索引的維護 (N)
FEEDBACK               每 x 行顯示進度 (0)
TOID_NOVALIDATE        跳過指定型別 ID 的驗證
FILESIZE               每個轉儲檔案的最大大小
STATISTICS             始終匯入預計算的統計資訊
RESUMABLE              在遇到有關空間的錯誤時掛起 (N)
RESUMABLE_NAME         用來標識可恢復語句的文字字串
RESUMABLE_TIMEOUT      RESUMABLE 的等待時間
COMPILE                編譯過程, 程式包和函式 (Y)
STREAMS_CONFIGURATION  匯入流的一般元資料 (Y)
STREAMS_INSTANTIATION  匯入流例項化元資料 (N)
DATA_ONLY              僅匯入資料 (N)

下列關鍵字僅用於可傳輸的表空間
TRANSPORT_TABLESPACE 匯入可傳輸的表空間元資料 (N)
TABLESPACES 將要傳輸到資料庫的表空間
DATAFILES 將要傳輸到資料庫的資料檔案
TTS_OWNERS 擁有可傳輸表空間集中資料的使用者

成功終止匯入, 沒有出現警告。

#加入忽略索引、授權、約束
C:\app\oracle\product\12.1.0\dbhome_1\BIN>imp test/[email protected]:1521/pyang1 file=c:\SDYD_test.dmp  GRANTS=N INDEXES=N touser=test fromuser=HR CONSTRAINTS=N

Import: Release 12.1.0.2.0 - Production on 星期二 315 19:27:36 2016

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


連線到: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

經由常規路徑由 EXPORT:V09.02.00 建立的匯出檔案

警告: 這些物件由 SYSTEM 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
匯出伺服器使用 UTF8 NCHAR 字符集 (可能的 ncharset 轉換)
. 正在將 HR 的物件匯入到 TEST
. . 正在匯入表     "HR_ALL_ORGANIZATION_UNITS"匯入了        4507 行
即將啟用約束條件...
成功終止匯入, 沒有出現警告。

C:\app\oracle\product\12.1.0\dbhome_1\BIN>imp test/[email protected]:1521/pyang1 file=c:\SDYD_test.dmp   GRANTS=N INDEXES=N touser=test fromuser=APPLSYS CONSTRAINTS=N

Import: Release 12.1.0.2.0 - Production on 星期二 315 19:28:11 2016

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


連線到: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

經由常規路徑由 EXPORT:V09.02.00 建立的匯出檔案

警告: 這些物件由 SYSTEM 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
匯出伺服器使用 UTF8 NCHAR 字符集 (可能的 ncharset 轉換)
. 正在將 APPLSYS 的物件匯入到 TEST
. . 正在匯入表                      "FND_USER"匯入了        3415 行
成功終止匯入, 沒有出現警告。

C:\app\oracle\product\12.1.0\dbhome_1\BIN>