Constraint [message #591901] |
Thu, 01 August 2013 06:03 |
|
satheesh_ss
Messages: 61 Registered: July 2012
|
Member |
|
|
mysql> use new;
Database changed
mysql> show tables;
+---------------+
| Tables_in_new |
+---------------+
| books |
| dvds |
| employee |
| orders |
| penalties |
| professor |
| studios |
| topic |
| users_profile |
+---------------+
9 rows in set (0.00 sec)
mysql> show create table books;
+-------+---------------------------------------------------------------------------------
| Table | Create Table
+-------+---------------------------------------------------------------------------------
| books | CREATE TABLE `books` (
`BookID` smallint(6) NOT NULL,
`BookName` varchar(40) NOT NULL,
`InStock` smallint(6) NOT NULL,
PRIMARY KEY (`BookID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+---------------------------------------------------------------------------------
1 row in set (0.00 sec)
mysql> drop table books;
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
As i am new to MYSQL , i dont know how to drop the table which contains Primary key column and it was an dependent object to the other table. When i use to drop the table, i m getting error as i showed above.
Also In the above table BOOKS, i want to know which table references the BOOKS table.
kindly suggest me an answer.
|
|
|
Re: Constraint [message #591902 is a reply to message #591901] |
Thu, 01 August 2013 06:11 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
I don't use MySQL. However: as you saw, you can't drop a table whose primary key is referenced by a foreign key.
Google says that this page (among many of them) contains information about finding foreign key constraints. Have a look.
|
|
|