Reputation: 21
I get the following error:
Database error 1091 while doing query Can't DROP 'indexname'
; check that column/key exists
Is there any way to check if an index exists before you drop it without using stored procedures?
Upvotes: 1
Views: 3875
Reputation: 440
This worked for me
DROP INDEX IF EXISTS unique_name ON mytable;
alter table mytable add unique unique_name (....)
unique_name is the constraints name and mytable is the table its applied on.
Hope this helps
Upvotes: 1
Reputation: 31991
Try by using SHOW INDEX
SHOW INDEX FROM Your_table
It will help to know index name of any column
SELECT * FROM information_schema.statistics
WHERE table_schema = 'your_databasename'
AND table_name = 'your_tablename' AND column_name = 'column_name'
For more details
Upvotes: 1