← Torna a MySQL
Articoli correlati
Esempi
Esempio #1
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;
Esempio #2
SET @tabella = '<%PREFIX%>_messages';
SET @indice = 'reference';
SET @exist := (SELECT COUNT(*) FROM information_schema.statistics WHERE `table_name` = @tabella and `index_name` = @indice and `table_schema` = database());
SET @sqlstmt := IF( @exist > 0 , CONCAT( 'ALTER TABLE ', @tabella, ' DROP INDEX ', @indice, ';' ), 'SELECT ''INFO: Indice non trovato.''');
PREPARE stmt FROM @sqlstmt;
EXECUTE stmt;