Quote:
Originally posted by aus
No, this is a known and documented operation. When a "parent" table is dropped, any foreign keys that reference the table are dropped as well.
|
Oracle does not allow the user to drop the Parent table before dropping the referencing Child table.
In fact in MySQL, when we drop the Parent table, the foreign key constraints still exist in the Child table. Please look at the below list of statements. (Note that I dont even have the on delete cascade in the child table).
-----------------------------------------------------------------------------
mysql> create table parent (ssn int primary key) type=innodb;
Query OK, 0 rows affected (0.03 sec)
mysql> create table child (ssn int, index(ssn), foreign key(ssn) references parent(ssn)) type=innodb;
Query OK, 0 rows affected (0.05 sec)
mysql> insert into parent values(1);
Query OK, 1 row affected (0.09 sec)
mysql> insert into child values (1);
Query OK, 1 row affected (0.06 sec)
mysql> drop table parent;
Query OK, 0 rows affected (0.03 sec)
mysql> insert into child values (2);
ERROR 1216: Cannot add or update a child row: a foreign key constraint fails
------------------------------------------------------------------------------
Thanks,
Prasanna