Bug #19354 CREATE INDEX lacks of IF NOT EXISTS
Submitted: 25 Apr 2006 21:05 Modified: 12 May 2006 17:38
Reporter: cristian vanti Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.1 OS:Any (all)
Assigned to: MySQL Verification Team CPU Architecture:Any

[25 Apr 2006 21:05] cristian vanti
Description:
There is no way to create an index only if it not exists. 
Inside a batch script 
you can't insert a:
IF NOT EXISTS (SELECT 1 FROM all_indexes WHERE name='idx_something') THEN
  CREATE INDEX idx_something ON ...;
END IF;

you can't insert a:
  CREATE INDEX IF NOT EXISTS idx_something ON ...

you can't insert a:
  DROP INDEX IF EXISTS idx_something (and it wouldn't be a solution: if table is big it'd be a big waste of time)

How to repeat:
CREATE INDEX IF NOT EXISTS idx_something ON ...
[26 Apr 2006 2:30] MySQL Verification Team
Thank you for the bug report. Looks to me it is a feature request and
I guess already reported. Do you agree?
[26 Apr 2006 13:04] cristian vanti
yes it's a feature request. I inserted wrong severity. Now it's correct.

bye
[12 May 2006 17:38] Valeriy Kravchuk
I think, it is a duplicate of bug #15287. Work in progress already.
[26 Mar 2010 23:07] Cowtown Coder
Actually it looks like referenced bug did not explicitly list "CREATE INDEX" as missing this option. It probably should.