刚学习使用了expdp与impdp的用法。
有以下3点疑问。
1. 不指定directory 的情况,反复导出数据,需要重新指定dumpfile名?
2. 不指定directory 的情况,导入数据成功,但“completed with 1 error(s)”
3. 想指定directory 的情况,导出数据失败?我只有20分,都给了~~~具体如下
首先不指定directory 的情况。
expdp liuzq/123456 tables=BM dumpfile=BM4.dmp job_name=BM_EXPORT导出成功。
再执行一遍的话,会失败
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31641: unable to create dump file "/usr/u03/admin/devorcl/dpdump/BM4.dmp"
ORA-27038: created file already exists
Additional information: 1疑问1. 反复使用expdp,如何可以不重新指定文件名而覆盖原来的导出文件BM4.dmp?
然后,truncate table BM; 导入数据。
impdp liuzq/123456 tables=BM dumpfile=BM4.dmp job_name=BM_EXPORT table_exists_action=append疑问2. 数据成功导入,但“completed with 1 error(s)”,不知是何缘故?
Import: Release 11.1.0.6.0 - 64bit Production on Tuesday, 08 November, 2011 15:19:48Copyright (c) 2003, 2007, Oracle.  All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "LIUZQ"."BM_EXPORT" successfully loaded/unloaded
Starting "LIUZQ"."BM_EXPORT":  liuzq/******** tables=BM dumpfile=BM4.dmp job_name=BM_EXPORT table_exists_action=append
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39152: Table "LIUZQ"."BM" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "LIUZQ"."BM"                                7.546 KB      49 rows
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
==>  Job "LIUZQ"."BM_EXPORT" completed with 1 error(s) at 15:19:51
由于,前面没有指定directory,现在想在指定的目录导出数据,于是
SQL>  create directory zdpdata as '/home/z/dpdata';Directory created.此目录存在
drwxrwxrwx 2 z dev 4096 11-08 14:25 dpdata
expdp liuzq/123456 tables=BM directory=zdpdata dumpfile=BM.dmp job_name=BM_EXPORT
疑问3. 但总是失败,不知是何原因
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 488
ORA-29283: invalid file operation

解决方案 »

  1.   

    疑问1:不建立目录?如果没有目录是会报错的,一般都回指定目录的疑问2:ORA-39152: Table "LIUZQ"."BM" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append就是提示你表已经存在,看信息疑问3:liuzq/123456 这个用户没有目录读写权限?GRANT下
     
      

  2.   

    谢谢1楼的回答,但还有些疑问想请教下:针对疑问1:目录存在,只是不指定目录,没有这样的参数“directory=zdpdata”。这样Oracle会dump到系统默认的目录下面。
    我的问题是,反复expdp到同一地方,dumpfile名一样。第二遍就失败了,因为“created file already exists”,没有办法覆盖原来的dumpfile吗?
    针对疑问2:导入数据方式是table_exists_action=append,所以预想表就是存在的。
    然后,数据也成功导入到表里面,但是给出的信息让人疑惑:“completed with 1 error(s)”
    虽说给了个message,但算不上error吧
    针对疑问3:zdpdata 是用户“liuzq”建立的,用其他用户grant,也成功了
    SQL> grant read, write on directory zdpdata to liuzq;Grant succeeded.但 expdp liuzq/123456 tables=BM directory=zdpdata dumpfile=BM.dmp job_name=BM_EXPORT
    总是失败。
      

  3.   

    疑问3 的原因找到了。是因为上层目录没有权限写,导致zdpdata as '/home/z/dpdata'里文件没有生成。重新指定到一个777权限的目录下,就可以了。
    -rw-r----- 1 oracle oinstall 102400 Nov  8 18:06 BM.dmp发现使用expdp后生成的文件权限并不是当前用户,而是”oracle” 用户。
    使用exp后生成的文件权限是当前用户。
      

  4.   

    疑问1:应该也是权限的问题疑问2:就比较奇怪,虽是error,但数据成功导入,暂不追究了疑问3:楼上已给出原因。