获取任何表的当前 AUTO_INCREMENT 值

2021-11-20 00:00:00 mysql auto-increment

如何获取 MySQL 中表的当前 AUTO_INCREMENT 值?

How do I get the current AUTO_INCREMENT value for a table in MySQL?

推荐答案

您可以使用此查询获取所有表数据:

You can get all of the table data by using this query:

SHOW TABLE STATUS FROM `DatabaseName` WHERE `name` LIKE 'TableName' ;

您可以使用此查询准确获取此信息:

You can get exactly this information by using this query:

SELECT `AUTO_INCREMENT`
FROM  INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'DatabaseName'
AND   TABLE_NAME   = 'TableName';

相关文章