Mysql:mysql cannot delete the foreign key, rename error on the./ruler/test2child to./ruler/#sql2 -298-92 (errno:152)
It used to be a bug in MySQL, but now it's just an unfriendly place in MySQL.
Examples are as follows:
mysql> ALTER TABLE ruler.test2child DROP FOREIGN KEY test;
ERROR 1025:error on Rename of './ruler/test2child './ruler/#sql2 -298-8f ' (errno:
152)
It is not possible to delete the foreign key, but to use the wrong foreign key name, but the MySQL newspaper's error is outrageous.
The correct error message is to be known by the following query:
Mysql> show InnoDB status;
------------------------
LATEST FOREIGN KEY error
------------------------
071222 20:48:26 Error in Dropping of a FOREIGN key constraint of table
"ruler". Test2child ", in
SQL command
ALTER TABLE ruler.test2child DROP FOREIGN KEY Test
cannot find a constraint with The given ID "test".
In addition, other foreign key operations have similar conditions:
such as foreign key new error:
Can ' t create table ' ruler #sql -298_92 ' (errno:150) show
innodb status;
------------------------
LATEST FOREIGN KEY error
------------------------
071222 20:18:57 Error in FOREIGN KEY constraint of table ruler/#sql -298_8d:
foreign Key (Test2code) REFERENCES ruler.test2 (test) on delete set Null:
have defined a SET NULL condition though some of the columns are as not
null.
The test database version is:
5.2.0-falcon-alpha-community-nt
To delete a foreign key:
First delete the foreign key name, then delete the Foreign key field (provided by the MySQL official)
Cases:
ALTER TABLE task drop foreign key fk_reference_7;
ALTER TABLE Task drop column ' assigned ';
The above is a small set to introduce the MySQL delete foreign key issues summary, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!