Mysql version upto 5.6, No straight-forward way to DROP INDEX using IF EXISTS.
Try this,
create procedure DeleteIndex()
begin
IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 'TableName'
AND INDEX_NAME = 'IndexName' AND INDEX_SCHEMA='DbName') THEN
ALTER TABLE TableName DROP index THead2;
END IF;
END
create procedure DeleteIndex()
begin
IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 'TableName'
AND INDEX_NAME = 'IndexName' AND INDEX_SCHEMA='DbName') THEN
ALTER TABLE TableName DROP index THead2;
END IF;
END
0 Comments