5 min read

How to reindex tables with MySQL

How to reindex tables with MySQL

Last modified

ALTER TABLE wp_posts CHANGE ID ID int(11) UNSIGNED NOT NULL;  -- Removes auto-inrement from ID
DROP INDEX `PRIMARY` ON wp_posts; -- Removes index PRIMARY from provided table
ALTER TABLE wp_posts ADD primary key (ID); -- Add index again

If you want to remove the auto-increment and the primary key from the ID column in a single SQL statement, this should do.


ALTER TABLE wp_posts DROP PRIMARY KEY, CHANGE ID ID int(11) UNSIGNED NOT NULL;
ALTER TABLE wp_posts ADD primary key (ID);