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未导入任何对象
执行imp xyz/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用户,因此需要对于这种导入导出用户名不同的情况,可以明确指定用户名称,执行:
imp xyz/xxx file=test.dmp log=imp_test.log fromuser=abc touser=xyz ignore=y commit=y buffer=300000000 feedback=10000
顺利执行导入操作了
今天从网上看了一个问题
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
. ......余下全文>>
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......余下全文>>