简体   繁体   中英

Why can't I drop a table on MYsql?

Here is the code:

USE new_schema;
DROP TABLE account;
ALTER TABLE transaction
DROP FOREIGN KEY fk_t_account_id;

the error:

09:10:05 DROP TABLE account Error Code: 3730. Cannot drop table 'account' referenced by a foreign key constraint 'fk_t_account_id' on table 'transaction'. 0.000 sec

Looks at the foreign key. That table also needs to be dropped or remove the foreign key constraint

Just switch the order of the SQL

USE new_schema;

ALTER TABLE transaction
DROP FOREIGN KEY fk_t_account_id;

DROP TABLE account;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM