如何找到所有的AUTO_INCREMENT表?

Art*_*tan 1 mysql auto-increment

我需要在具有 AUTO_INCREMENT 列的 MySQL 数据库模式中找到所有表。

我需要能够将所有这些表设置为一个大的 AUTO_INCREMENT 值,以免与将添加到(百万?)的基本数据重叠。

我知道这是一个坏主意,但我不希望每个表的基础数据超过 1000 个项目。

jsa*_*ata 5

use information_schema;
select table_name 
from tables 
where auto_increment is not null and table_schema=...;
Run Code Online (Sandbox Code Playgroud)

然后,您可以根据更改自动增量起始编号来设置自动增量值

或者,一次性(假设是 Unix shell):

mysql information_schema -e 
'select concat ("ALTER TABLE ",table_name," AUTO_INCREMENT=1000000") `-- sql` 
from tables 
where auto_increment is not null and table_schema="your-schema";
'|mysql your-schema
Run Code Online (Sandbox Code Playgroud)