php - How can I employ "if exists" for creating or dropping an index in MySQL? -


i wondering if there's way check if index exists before creating or destroying on mysql. appears there feature request few years back, can't find documentation solution. needs done in php app using mdb2.

here 4 liner:

set @exist := (select count(*) information_schema.statistics table_name = 'table' , index_name = 'index' , table_schema = database()); set @sqlstmt := if( @exist > 0, 'select ''info: index exists.''', 'create index i_index on tablename ( columnname )'); prepare stmt @sqlstmt; execute stmt; 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -