MySql:Cancellare un indice controllando prima se esiste

← Torna a MySQL

Articoli correlati

Esempio

SET @exist := (SELECT COUNT(*) FROM information_schema.statistics WHERE `table_name` = '<nome-tabella>' and `index_name` = '<nome-indice>' and `table_schema` = database());
SET @sqlstmt := IF( @exist > 0 , 'ALTER TABLE `<nome-tabella>` DROP INDEX `<nome-indice>`;', 'SELECT ''INFO: Indice non trovato.''');
PREPARE stmt FROM @sqlstmt;
EXECUTE stmt;