Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
Drop --temporary-- indexes in Mysql/Mariadb

I'm trying to recover a semi corrupted InnoDB table. I noticed the issue while trying to add a new index to the table.

ALTER TABLE `<table>` ADD INDEX `<name>`
ERROR 1712 (HY000): Index "TEST008"--temporary-- is corrupted

The check table <table> EXTENDED doesn't pick up on the issue.

+---------------+-------+----------+----------+
| Table         | Op    | Msg_type | Msg_text |
+---------------+-------+----------+----------+
| <table>       | check | status   | OK       |
+---------------+-------+----------+----------+

I have tried to drop the corrupted index using ALTER TABLE table DROP INDEX "TEST008"--temporary--\ but it ends up with

ERROR 1091 (42000): Can't DROP '"TEST008"--temporary--'; check that column/key exists

Am I forced to recreate the table using for example OPTIMIZE?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I concur with @nbk, if you can't get rid of a corrupted index you'll need to reconstruct the table. Do you make occasional back ups? In example I literally stop the database service and copy the entire database directory including the MariaDB binary and everything. Redundancy seems like overkill until you need it.

The most basic way to accomplish reconstructing the table is by using the following:

INSERT INTO `table_new` SELECT * FROM `table_old`;

There are some threads floating around the web about how to do that faster though this one I could test without errors in MariaDB. Just rename the old table in case you find a better approach after you reconstruct the table. I recently updated some database tables I created a decade ago after I was given bad advice from someone over naming conventions and now I can greatly expand the functionality of that software now if needed.

Good luck!

over 4 years ago · Santiago Trujillo Denunciar

0

You should check the indexes status which will not show under CHECK TABLE.

To do that, try the following

SHOW VARIABLES LIKE 'userstat';
SET GLOBAL USERSTAT = ON;
-- just to get all columns used from the stats table
-- SHOW COLUMNS FROM `INFORMATION_SCHEMA`.`INDEX_STATISTICS`

-- get all indices just in case
SELECT * FROM  `INFORMATION_SCHEMA`.`INDEX_STATISTICS`;

-- get all indices for the table
SELECT * FROM  `INFORMATION_SCHEMA`.`INDEX_STATISTICS` WHERE `TABLE_NAME` = 'yourTable';

That will clear out what is indexed and what is not in your tables.

Another thing is that when you add/drop indices better use ticks like \TEST008`` rather than "TEST008". If this neither works... clone/copy the table content, drop it and re-create it.

CREATE TEMPORARY TABLE `backupTable`
  SELECT * FROM `yourTable`;

For additional information please read Create Temporary table

Make sure that this will happen as this memory table could fail due to the size of the index size. If that happens you should increase or change HASH indexing algorithm in use.

If everything works as expected ADD the temp table lines on the next statement

Note: make sure to add all those missing fields

DROP TABLE IF EXISTS `yourTable`;
CREATE TABLE `yourTable`(
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  -- other columns
  PRIMARY KEY(`id`)
) Engine=InnoDB; -- or extend this with collation, and other instructions

INSERT INTO `yourTable`
  SELECT * FROM `backup`;

This should do the trick.

Last case solution is to hard remove from file system the InnoDB table but I doubt that this is the case.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda