Mysql修改自增主键的起始值及查询自增主键的下一个值

时间:2020-12-29 09:09:45

MySQL [xxx_mall]> alter table shop_base_info  AUTO_INCREMENT=11000;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

MySQL [xxx_mall]> SELECT
    -> auto_increment
    -> FROM
    -> information_schema.`TABLES`
    -> WHERE
    -> table_name = 'shop_base_info';
+----------------+
| auto_increment |
+----------------+
|          11001 |
+----------------+
1 rows in set (0.00 sec)

PS: 如果数据不足11000条,不影响前面的数据 ; 如果数据大于11000,则设置无效