Reset MySQL auto_increment when a large number already exists?

I have a table with an auto-increasing column. I need to set one of the lines to 1000 and never touch it again, but now that I set it to 1000, auto increment continues to start at 1001 and refuses to start at 1. Is there any way around this?

+5
source share
5 answers

You can not:

To change the value of the AUTO_INCREMENT counter that will be used for newlines, do the following:

ALTER TABLE t2 AUTO_INCREMENT = value;

reset , . MyISAM, AUTO_INCREMENT, reset . InnoDB, , , .

http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

+7

: .

, , 1 1000 ? - " " -error.

, , , 0? , 1000, , 1001?

+3

, 1000, , :

UPDATE  table.column SET id = 1000 WHERE id = current_id;

id - . current_id , ​​.

+1

MS Access, MySQL , MS Access Excel (-, Excel).

0

:

UPDATE tbl SET id=1000 WHERE id=current_id;
ALTER TABLE tbl AUTO_INCREMENT=1001;
0

All Articles