Answer the question
In order to leave comments, you need to log in
How to replace id for all records in a table?
Good day!
SELECT ID, COUNT(ID) AS c FROM wp_posts GROUP BY ID HAVING c > 1
#1062 - ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '6168' for key 'PRIMARY'
Answer the question
In order to leave comments, you need to log in
Found a solution in one of the questions. It helped, everything worked.
CREATE table wp_posts_copy LIKE wp_posts;
ALTER TABLE wp_posts_copy ADD PRIMARY KEY (id);
INSERT IGNORE INTO wp_posts_copy SELECT * FROM wp_posts; -- INSERT INGORE вставит только по одному экземпляру id.
DROP TABLE wp_posts;
RENAME TABLE wp_posts_copy TO wp_posts;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question