This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 188349 - Cannot drop cross-referenced Tables
Summary: Cannot drop cross-referenced Tables
Status: RESOLVED WONTFIX
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P3 normal (vote)
Assignee: Jiri Rechtacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-03 19:40 UTC by bht
Modified: 2011-04-07 07:05 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bht 2010-07-03 19:40:06 UTC
In Database Explorer, two tables cannot be dropped if both have foreign key contraints referencing each other.

This is relevant for some one-to-one relationships.

Testcase:

CREATE TABLE TABLE_1 (ID INTEGER NOT NULL, TABLE_2_ID INTEGER NOT NULL, PRIMARY KEY (ID));
CREATE TABLE TABLE_2 (ID INTEGER NOT NULL, TABLE_1_ID INTEGER NOT NULL, PRIMARY KEY (ID));
ALTER TABLE TABLE_1 ADD CONSTRAINT FK_TABLE_1_TABLE_2_ID FOREIGN KEY (TABLE_2_ID) REFERENCES TABLE_2 (ID);
ALTER TABLE TABLE_2 ADD CONSTRAINT FK_TABLE_2_TABLE_1_ID FOREIGN KEY (TABLE_1_ID) REFERENCES TABLE_1 (ID);

When trying to drop the tables in Database Explorer by right click|delete, the error is:
Unable to execute command:
drop table "APP"."TABLE_2"
Operation 'DROP CONSTRAINT' cannot be performed on object 'SQL100704071938090' because CONSTRAINT
'FK_TABLE_1_TABLE_2_ID' is dependent on that object.

This looks like a bug because Database Explorer seems to try to drop constraints two times.

This worked as expected:

ALTER TABLE TABLE_1 DROP CONSTRAINT FK_TABLE_1_TABLE_2_ID;
ALTER TABLE TABLE_2 DROP CONSTRAINT FK_TABLE_2_TABLE_1_ID;
DROP TABLE TABLE_1;
DROP TABLE TABLE_2;
Comment 1 Jiri Rechtacek 2010-07-12 14:04:05 UTC
It's one of known problems, part of considered improvements in DDL area.

*** This bug has been marked as a duplicate of bug 184492 ***
Comment 2 bht 2011-04-06 23:45:45 UTC
This does not appear to be fixed.
Comment 3 Jiri Rechtacek 2011-04-07 07:05:48 UTC
Sorry, we have no plans to fix this in the near future. Patches are welcome.