Re: Drop foreign key only if it exists
Hi Eugene,
Try:
DELIMITER $$
DROP PROCEDURE IF EXISTS `DropFK`$$
CREATE PROCEDURE `DropFK`()
BEGIN
IF EXISTS (SELECT NULL FROM information_schema.TABLE_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = DATABASE() AND CONSTRAINT_NAME = 'object_ibfk_1') THEN
ALTER TABLE `object` DROP FOREIGN KEY `object_ibfk_1`;
END IF;
END$$
DELIMITER ;
Subject
Views
Written By
Posted
29277
July 17, 2008 02:24AM
Re: Drop foreign key only if it exists
13773
July 17, 2008 08:21PM
10728
August 12, 2008 06:00AM
19246
February 11, 2009 01:32PM
12917
February 12, 2009 10:47AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.