2019-12-27
information_schema의 테이블들은 권한만 있으면 select가 가능하다.
SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_schema = 'DB이름' AND table_name = 'table이름';
그래서 위와 같은 쿼리를 써서 다음 AUTO_INCREMENT의 값을 가져 올 수 있다.

하지만 해당 db는 view만 가능하기 때문에,
UPDATE information_schema.tables SET AUTO_INCREMENT=23 WHERE table_schema = 'DB이름' AND table_name = 'table이름';
위와 같은 쿼리를 날리면 오류가 뜬다 root권한으로 접속 되어 있어도 안된다.

이럴때는, 아래와 같이 alter로 변경이 가능하다.
alter table `table이름` auto_increment = 1;