oracle中的import实用程序

时间:2010-03-25 17:42:51

标签: sql oracle oracle11g

我导出一个表空间。此表空间包含table1,其中两行表示rowa和rowb /

现在我删除了rowb并将新的rowc插入此表空间。

现在我导入了这个表空间。

导入后我看到表空间中的table1包含了 rowa,rowb,rowc但它假设包含rowa和rowb。

有人能说出这是为什么会这样吗?

1 个答案:

答案 0 :(得分:1)

我认为您使用的是旧的命令行IMP实用程序,而不是Datapump?

IMP不会删除现有表,也不会清除现有数据。如果我们设置标志IGNORE=Y,那么它将把它可以插入现有表中的数据并在日志文件中报告错误(重复键)。

这是当前的表格......

SQL> select * from t0;

COL1
----
rowA
rowC

SQL> 

......这就是我出口的......

SQL> select * from t0;

COL1
----
rowA
rowB

SQL> 

默认设置为IGNORE的导入失败,因为该表存在但更改标志成功:

SQL> host
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\temp>imp userid=APC tables=t0 file=apc.dmp

Import: Release 11.1.0.6.0 - Production on Thu Mar 25 18:22:21 2010

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

Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT:V11.01.00 via conventional path
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
. importing APC's objects into APC
. importing APC's objects into APC
IMP-00015: following statement failed because the object already exists:
 "CREATE TABLE "T0" ("COL1" VARCHAR2(4) NOT NULL ENABLE)  PCTFREE 10 PCTUSED "
 "40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUP"
 "S 1 BUFFER_POOL DEFAULT)                       LOGGING NOCOMPRESS"
Import terminated successfully with warnings.

C:\temp>imp userid=APC tables=t0 file=apc.dmp ignore=y

Import: Release 11.1.0.6.0 - Production on Thu Mar 25 18:22:33 2010

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

Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT:V11.01.00 via conventional path
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
. importing APC's objects into APC
. importing APC's objects into APC
. . importing table                           "T0"
IMP-00019: row rejected due to ORACLE error 1
IMP-00003: ORACLE error 1 encountered
ORA-00001: unique constraint (APC.SYS_C001014543) violated
Column 1 rowA          1 rows imported
Import terminated successfully with warnings.

C:\Documents and Settings\clarkean>exit

SQL> 

注意:一行被拒绝(因为COL1是主键)并且插入了一个rwo。因此该表现在有三行:

SQL> select * from t0;

COL1
----
rowA
rowB
rowC

SQL>

如果您的导入/导出过程确实将数据/数据结构替换为导入,那么您应该使用Datapump。实际上你应该使用Datapump,因为它实际上是更好的实用程序。 Find out more