如何从我的 MySQL 表中删除约束?

2022-01-20 00:00:00 constraints foreign-keys mysql alter

我想从我的表中删除约束.我的查询是:

I want to remove constraints from my table. My query is:

ALTER TABLE `tbl_magazine_issue` 
DROP CONSTRAINT `FK_tbl_magazine_issue_mst_users`

但我得到了一个错误:

#1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的约束 FK_tbl_magazine_issue_mst_users"附近使用正确的语法

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'constraint FK_tbl_magazine_issue_mst_users' at line 1

推荐答案

Mysql 有一个特殊的语法来删除外键约束:

Mysql has a special syntax for dropping foreign key constraints:

ALTER TABLE tbl_magazine_issue
  DROP FOREIGN KEY FK_tbl_magazine_issue_mst_users

相关文章