Reputation: 15
I have big MySql table 'docs' (above 3 000 000 rows).
This table have column id
--- primary key unsigned and did
----- unsigned.
Sometimes some rows deleted. But I need that autoincrement go 1234 and not 1479.
I perform sql request:
update docs set id=@num:=@num+1 where 0 in(select @num:=0)
and receive error #1062.
2 questions: 1. Why I have duplicate entry for the key primary? 2. How I can delete them?
Upvotes: 0
Views: 1003
Reputation: 15
My idea is more easy (remove and add primary):
ALTER TABLE docs
DROP id
;
ALTER TABLE docs
ADD id
INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (id
);
Upvotes: 0