Useful shortcuts for vi editor

Showing posts with label ORA-02266. Show all posts
Showing posts with label ORA-02266. Show all posts

Wednesday, 25 October 2017

ORA-02266 solution

Action
A table has a PK (Primary Key)
B table has a FK (Foreign Key) and referenced to A table's PK

-> User tries to truncate table A

Error
ORA-02266: unique/primary keys in table referenced by enabled foreign keys

Solution I
Disable B table's FK
SQL> alter table HR.B disable constraint FK_B;
-- e.g. schema HR

Solution II
First truncate table B
SQL> truncate table B;

Then truncate table A
SQL> truncate table A;