Differenze tra le versioni di "MySql:Cancellare un indice controllando prima se esiste"

(Creata pagina con "← Torna a MySQL Esempio: <pre> SET @exist := (SELECT COUNT(*) FROM information_schema.statistics WHERE `table_name` = '<nome-tabella>' and `index_name...")
(Nessuna differenza)

Versione delle 10:03, 21 set 2022

← Torna a MySQL

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;