D/MySQL

MySQL AUTO_INCREMENT 값 수정

yeon.Biju 2020. 3. 13. 09:26

auto_increment 값을 변경하는 쿼리

 

 

mysql> ALTER TABLE tbl_name AUTO_INCREMENT =100;

 

 

 

mysql> create table test11 (idx int auto_increment primary key, content text) ;
Query OK, 0 rows affected (0.08 sec)

mysql> insert into test11 (content) values ('test');
Query OK, 1 row affected (0.00 sec)

mysql> alter table test11 auto_increment=100;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> insert into test11(content) values  ('test2');
Query OK, 1 row affected (0.01 sec)

mysql> select * from test11 order by idx desc ;
+-----+---------+
| idx | content |
+-----+---------+
| 100 | test2   |
|   1 | test    |
+-----+---------+
2 rows in set (0.00 sec)