RDB/MySQL

mysql auto_increment 변경

세모데 2020. 2. 14. 15:43

1. auto increment 설정 확인

   1) 전체

   select table_name, auto_increment from information_schema.tables where table_schema = 'test' and auto_increment is not null

 

   2) 상세내용

   show create table test_table;

 

2. 기존 테이블 auto increment 설정

   alter table test.test_table modify id bigint not null auto_increment;

   => 설정하면 해당 컬럼에 있는 최대값으로 auto_increment 값이 자동으로 조정됨

 

3. auto increment 값 변경

   alter table test_table auto_increment = 10;