www

insert할 때의 auto_increment값 알아내기

잡T 2019. 12. 29. 09:42

query를 사용하다보면 insert할 때의 auto_increment 값이 필요할 때가 있다.

아래처럼 쿼리를 작성하면 된다. 밑줄 친 table_name에 해당 테이블명을 써주면 된다.

“SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = ‘table_name‘ AND table_schema = DATABASE();”

 

또는 아래링크를 참고.
https://stackoverflow.com/questions/15821532/get-current-auto-increment-value-for-any-table