Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!