5

我必须将表从 Oracle 数据库复制到 db2 v7 数据库中,为了做到这一点(避免数百万次删除和创建),我想知道 db2 是否具有类似 Oracle 的功能,可以临时启用/禁用约束而不删除他们。

在此先感谢,毛罗。

4

2 回答 2

5

你可以做:

ALTER TABLE <table-name> ALTER FOREIGN KEY <constraint-name> NOT ENFORCED

然后重新启用:

ALTER TABLE <table-name> ALTER FOREIGN KEY <constraint-name> ENFORCED

http://publib.boulder.ibm.com/infocenter/mptoolic/v1r0/index.jsp?topic=/com.ibm.db2tools.ama.doc.ug/amacric0.htm

于 2010-03-22T21:59:49.920 回答
1

I'm not sure if this works in version 7, but you can try the following:

set integrity for table_name off
set integrity for table_name foreign key immediate unchecked

And then you can do your inserts. To re-enable, you can then do the following:

set integrity for table_name immediate checked
于 2009-01-07T18:59:32.667 回答