Disable Primay Key
Hi All,
My DB Version is 11.2.0.2
I want to update a column which is part of Primary Key. Same column is also a foreign key from other table.
{CREATE TABLE test1 (
testid VARCHAR2(32) NOT NULL,
key1 NUMBER NOT NULL,
key2 VARCHAR2(60) NOT NULL,
key3 NUMBER NOT NULL,
percentage NUMBER(5,2) NULL,
amount NUMBER(7,5)
)
STORAGE (
INITIAL 1024 K
NEXT 1024 K
)
LOGGING
/
CREATE INDEX test1_idx1
ON test1 (
key1,
key2,
key3
)
STORAGE (
INITIAL 1024 K
NEXT 1024 K
)
LOGGING
/
ALTER TABLE test1
ADD CONSTRAINT test1_pk4 PRIMARY KEY (
testid,
key1,
key2,
key3
)
USING INDEX
STORAGE (
INITIAL 1024 K
NEXT 1024 K
)
LOGGING
/
ALTER TABLE test1
ADD CONSTRAINT test2_test1_fk3 FOREIGN KEY (
key1,
key2,
key3
) REFERENCES test2 (
key1,
key2,
key3
)
/
ALTER TABLE test1
ADD CONSTRAINT test1_fk_testid FOREIGN KEY (
testid
) REFERENCES test3 (
testid
)
/
}
I tried disable validate / Initially deferred .... but still on update i am getting error
"ORA-00001: unique constraint violated"
below are the stmts that i tried executing
Method 1:
{
ALTER TABLE test1
DISABLE PRIMARY KEY KEEP INDEX;
}
Method 2:
{
ALTER TABLE test1
DISABLE constraint test1_fk_testid;
ALTER TABLE test1
DISABLE constraint test1_pk4;
}
Method 3:
{
ALTER TABLE test1
DISABLE constraint test1_fk_testid;
ALTER TABLE test1
disable VALIDATE CONSTRAINT test1_pk4;
}
Method 4:
{ set constraints test1_pk4;, test1_fk_testid deferred ;
}
but this throws error
ORA-02447: cannot defer a constraint that is not deferrable
Can anyone help me out in solving the problem.....