如何使导入顺利完成!

当做 exp导入的时候可能会遇到约束的问题而不能进行导入。

可以使用下面的办法来禁止约束从而使导入顺利完成!

在导入的时候遇到如下问题:

Column 30 MOS
IMP-00019: row rejected due to ORACLE error 2291
IMP-00003: ORACLE error 2291 encountered
ORA-02291: integrity constraint (CMDB.CI_ELEMENT_LOCATION) violated - parent key not found

处理步骤如下:

SQL> create table cmdb.configuration_item_bak as select * from cmdb.configuration_item;

Table created.

SQL> alter table cmdb.configuration_item disable primary key;
alter table cmdb.configuration_item disable primary key
*
ERROR at line 1:
ORA-02297: cannot disable constraint (CMDB.PK_CONFIGURATION_ITEM) -
dependencies exist


SQL> alter table cmdb.configuration_item disable constraint PK_CONFIGURATION_ITEM;
alter table cmdb.configuration_item disable constraint PK_CONFIGURATION_ITEM
*
ERROR at line 1:
ORA-02297: cannot disable constraint (CMDB.PK_CONFIGURATION_ITEM) -
dependencies exist


SQL> alter table cmdb.configuration_item disable constraint PK_CONFIGURATION_ITEM cascade;

Table altered.

SQL> alter table cmdb.configuration_item disable primary key;

Table altered.

SQL> alter table cmdb.configuration_item disable constraint PK_CONFIGURATION_ITEM ;

Table altered.

原以为这样做导入就应该没有问题了:)

imp / file=cmdb.dmp fromuser=cmdb touser=cmdb ignore=y

可问题依旧?

为什么呢。原来这里的约束错误是因为违反了文件里要导入数据的约束条件,这与是否禁止表上面的约束无关。

只是因为表中已经有了和文件里一样的数据导致在导入的时候违反了文件里的约束。

所以可以通过清除表里数据的办法来完成导入。

truncate table cmdb.configuration_item ;

然后导入:

-bash-3.00$ imp / file=cmdb.dmp fromuser=cmdb touser=cmdb ignore=y

Import: Release 11.2.0.2.0 - Production on Wed Aug 17 03:27:17 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning option

Export file created by EXPORT:V11.02.00 via conventional path
import done in UTF8 character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
export client uses US7ASCII character set (possible charset conversion)
. importing CMDB's objects into CMDB
. . importing table "CONFIGURATION_ITEM" 21171 rows imported

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值