我做一个表空间的导出。这个表空间包含 table1 有两行,比如 rowa 和 rowb/
现在我删除 rowb 并将新的 rowc 插入这个表空间。
现在我导入这个表空间。
导入后,我看到表空间中的 table1 包含 rowa、rowb、rowc,但假设它包含 rowa 和 rowb。
谁能告诉为什么会这样?
我想您使用的是旧的命令行 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,因为它总体上是更好的实用程序。 了解更多。