DROP PRIMARY KEY doesn't drop the UNIQUE INDEX
Hello!
We have a problem with an auto-index from a primary key (PK), which is not dropped when removing the PK. When creating PKs, oracle automatically adds a unique index to hold the primary key rule. When the pk is dropped the index is dropped too. This works fine as long as both statements (create and drop) are performed on either Oracle 9 or Oracle 10, i.e. both statements run on the same version.
If the database is transferred from Oracle 9 to 10 between both statements the index persists.
To reproduce:
- Create a primary key under Oracle 9 and export the Database
- Import it in Oracle 10
- Drop the primary key
Result:
Oracle 10 does not drop the unique Index created with the primary key!
Sample SQL:
-- run this on oracle 9 --
CREATE TABLE test ( pk INTEGER );
ALTER TABLE test ADD CONSTRAINT xpk_test PRIMARY KEY ( pk );
-- make an dump with exp and import it on Oracle 10
-- run this on oracle 10 --
ALTER TABLE test DROP CONSTRAINT xpk_test;
-- now only the primary key xpk_test is dropped, the index xpk_test stays
Why?
How to we avoid this behaviour? Is there a special method to deal with old (migrated) primary keys/indexes?
Any hint would be appreciated!
TIA,
F.