impdp導致主鍵索引的變化

kisslfcr發表於2018-05-18
在使用資料泵匯入資料時,有時需要禁用掉主鍵約束。
這樣做在特定情況下會存在匯入資料後主建索引丟失和主鍵對應的索引變化的問題。
官方支援如下。
禁用約束,刪除索引:
Oracle? Database Administrator's Guide 11g Release 2 (11.2)--》Managing Integrity Constraints
You can use the ALTER TABLE statement to enable, disable, modify, or drop a constraint. When the database is using a UNIQUE or PRIMARY KEY index to enforce a constraint, and constraints associated with that index are dropped or disabled, the index is dropped, unless you specify otherwise.


重建約束後會自動選擇唯一鍵:
Why Does The Primary Key Constraint Point To A Different Index After Import? (文件 ID 1455492.1)


During import, this sequence order is kept. When adding a primary/unique key constraint (step 3), Oracle checks if any existing index can be utilized to enforce the constraint, and in that case, uses it instead of creating a unique index (which was done before in 7.x releases unconditionally). This was done to minimize disk utilization and time needed for the constraint to be enabled.

可以在禁用約束時候使用keep index選項。
或者採用刪除和重建的方式。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2154659/,如需轉載,請註明出處,否則將追究法律責任。

相關文章