Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DROP PROCEDURE IF EXISTS `drop_index_if_exists`;
- DELIMITER $$
- CREATE PROCEDURE `drop_index_if_exists`(in theTable varchar(128), in theIndexName varchar(128) )
- BEGIN
- IF((SELECT COUNT(*) AS index_exists FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE() and table_name =
- theTable AND index_name = theIndexName) > 0) THEN
- SET @s = CONCAT('DROP INDEX `' , theIndexName , '` ON `' , theTable, '`');
- PREPARE stmt FROM @s;
- EXECUTE stmt;
- END IF;
- END$$
- DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement