Today colleagues let me delete a table of data, happy to say yes;
It looks like a simple task, it can be tricky to do, originally this table is a foreign key constraint, as a primary table exists.
But I just got in touch with the system, but it's hard to die.
Then I checked the data. Confirm that the constraint name can be queried to the appropriate table to disable the constraint, which solves the
Here's how I do the experiment:
First build two tables:
CREATE TABLE T_group (ID int not null,name varchar (), primary key (ID));
CREATE TABLE T_user (ID int not null,name varchar (), GroupID int,primary key (ID), foreign key (GroupID) references P (ID));
Insert data:
INSERT into T_group values (1, ' Group1 ');
INSERT into T_group values (2, ' Group2 ');
INSERT into T_user values (1, ' qianxin ', 1);
INSERT into T_user values (2, ' Yiyu ', 2);
Attempt to delete the T_group data error. As shown in Figure I
From the table by dba_constraints query according to the constraint name
Select Constraint_name, Constraint_type, table_name from dba_constraints where Constraint_name=upper (' sys_c005376 ');
Disable constraint below
ALTER TABLE t_user disable constraint sys_c005376;
Try to delete the data again
Delete from T_group;
Delete the success "" "" "The" "" "" "" "," "" "The" "", "" ""