exp/imp碰到的兩則問題處理(ORA-00904和the objects were exported by ABC not by you),ora-00904exported
最近負責搭建某系統的使用者環境,其中涉及從測試環境匯入資料,由於受客觀因素制約,不能使用傳輸資料表空間方法同步,因此需要用imp/exp或資料泵的方法,這裡採用的是imp/exp。下面記錄操作過程中碰到的問題。
問題1:exp匯出時ORA-00904: "IFREEPOOL": invalid identifier和"OLEVEL": invalid identifier錯誤
第一次操作時:
用於執行imp/exp的版本是:10.2.0.4
用於匯出的資料庫版本是:10.2.0.3
執行exp abc/xxx file=test.dmp log=exp_test.log
過程中有一些警示:
EXP-00008: ORACLE error 904 encountered
ORA-00904: "IFREEPOOL": invalid identifier
...
EXP-00008: ORACLE error 904 encountered
ORA-00904: "OLEVEL": invalid identifier
...
EXP-00000: Export terminated unsuccessfully
這篇MOS文章(726182.1)介紹了這種問題的原因:
如果源庫是10.2.0.3,那麼匯出用戶端需要是10.2.0.3版本,主要原因在於匯出工具會一直訪問資料字典對象,例如SYS.EXU9LOG,但10.2.0.4中引入了一個新列“IFREEPOOL“,10.2.0.3中沒有此列資訊,因此不能操作。
從這裡可以看出問題可能出在對LOB對象的表操作,workaround就是使用10.2.0.3及以下版本。於是這使用了10.2.0.1版本,匯出沒有如上的報錯了。
問題2:匯入時Warning: the objects were exported by ABC not by you未匯入任何對象
執行impxyz/xxx file=test.dmp log=imp_test.log ignore=y commit=y buffer=300000000 feedback=10000
過程中提示:
Warning: the objects were exported by ABC, not by you
...
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing RTCRM's objects into UAT_RTCRM
Import terminated successfully without warnings.
沒有任何對象匯入到目標庫。
上面的錯誤內容Warning: the objects were exported by RTCRM, not by you,指的是即將匯入的資料屬於ABC使用者,但匯入時使用的是XYZ使用者,因此需要對於這種匯入匯出使用者名稱不同的情況,可以明確指定使用者名稱稱,執行:
impxyz/xxx file=test.dmp log=imp_test.logfromuser=abc touser=xyzignore=y commit=y buffer=300000000 feedback=10000
順利執行匯入操作了
imp 匯入資料問題
今天從網上看了一個問題
imp匯入資料,能不能讓導進來的表名跟原來匯出的表名不同,也就是換個新的表名呢?
imp system/system file=mydmp.dmp fromuser=myuser1 touser=myuser2 tables=(mytable1)
這樣能把dmp匯出檔案裡面myuser1.mytable1匯入到myuser2,但表名還是mytable1,能不能讓導進來之後變為其他表名,比如mytable2?
請各位高手指點,謝謝!
藉助synonym可以實現這個需求!
比如原來有個schema: user_a,在user_a下有個表test
先exp user_a的test表到dmp
然後在user_a下建個表test_new,create table test_new as select * from test_a where 1=0;
然後在另外一個使用者(比如system)下建一個synonym
create synonym test for user_a.test_new;
接著把dmp檔案匯入到system下,自然就到了user_a.test_new了,最後把system下的synonym drop掉就OK了。
===========================
sqlplus fan/fan
SQL> create table fan_1 as select * from dba_objects;
Table created.
SQL> create table fan_2 as select * from fan_1 where rownum<1;
Table created.
exp fan/fan tables=fan_1 file=fan_1.dmp
sqlplus wrj/wrj
create or replace fan_1 for fan.fan_2;
select count(*) from fan_1;
0
$ imp wrj/wrj file=/oracle/fan_1.dmp commit=y ignore=y full=y
Import: Release 9.2.0.6.0 - Production on Thu Aug 28 15:59:56 2008
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 file created by EXPORT:V09.02.00 via conventional path
Warning: the objects were exported by FAN, not by you
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing FAN's objects into WRJ
. ......餘下全文>>
oracle怎將Scott中的表Copy到另一使用者
exp匯出:
exp userid=scott/tiger file='d:\exp.dmp' log='d:\exp.log' tables=(EMP,DEPT)
imp匯入
imp userid="\"sys/sys as sysdba"\" file='d:\exp.dmp' log='d:\imp.log' tables=(EMP,DEPT) fromuser=scott touser=test
注意:
執行匯入匯出的時候,命令是在作業系統上執行,不是在資料庫裡執行。
命令最後不要帶分號";"。
log參數可以不要。
匯入時,userid必須具有dba許可權才行,否者會報錯:
IMP-00007: must be a DBA to import objects to another user's account
如果scott有dba許可權,也可以用如下指令碼匯入:
imp userid=scott/tiger file='d:\exp.dmp' log='d:\imp.log' tables=(EMP,DEPT) fromuser=scott touser=test
執行個體如下:
C:\Documents and Settings\ty>exp userid=scott/tiger file='d:\exp.dmp' log='d:\exp.log' tables=(EMP,DEPT)
Export: Release 10.2.0.1.0 - Production on Fri Mar 5 09:31:54 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table EMP 14 rows exported
. . exporting table DEPT 4 rows exported
Export terminated successfully without warnings.
C:\Documents and Settings\ty>imp userid="\"sys/sys as sysdba"\" file='d:\ex......餘下全文>>