Drop foreign key only if it exists

前端 未结 7 2070
清歌不尽
清歌不尽 2021-02-05 01:37

I\'m on a MySQL database.

I\'m doing this, but it doesn\'t work.

ALTER TABLE `object` DROP FOREIGN KEY IF EXISTS `object_ibfk_1`;

I\'ve

7条回答
  •  温柔的废话
    2021-02-05 02:27

    In the current version of Mariadb 10.1.26 (new Mysql), your query works:

    Key: MUL

    ALTER TABLE `object` DROP FOREIGN KEY IF EXISTS `object_ibfk_1`;
    DESC `object`;
    

    Key:

提交回复
热议问题