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 tried to put this IF EXISTS wherever I could. How can check if foreign key is exists before drop it?
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 tried to put this IF EXISTS wherever I could. How can check if foreign key is exists before drop it?
Here is a workaround for the
DROP FOREIGN KEY IF EXISTS
, that is missing in MySQL and MariaDB versions beforev10.1.4
. You can also use it for every other statement you want, that should be depend on the existence of anFOREIGN KEY
(e.g. forSELECT "info: foreign key exists."
like in the example below).