如何通過MySql查看與修改auto_increment的方法

本文將介紹如何查看表的auto_increment及其修改方法

查看表當前auto_increment

表的基本數據是存放在mysql的information_schema庫的tables表中,我們可以使用sql查出。

select?auto_increment?from?information_schema.tables?where?table_schema='db?name'?and?table_name='table?name';

例子:查看 test_user 庫的 userauto_increment

mysql>?select?auto_increment?from?information_schema.tables?where?table_schema='test_user'?and?table_name='user'; +----------------+|?auto_increment?| +----------------+|???????????1002?| +----------------+1?row?in?set?(0.04?sec)

修改表auto_increment

alter?table?tablename?auto_increment=NUMBER;

例子:修改 test_useruserauto_increment10000

mysql>?alter?table?test_user.user?auto_increment=10000; Query?OK,?0?rows?affected?(0.12?sec) Records:?0??Duplicates:?0??Warnings:?0mysql>?select?auto_increment?from?information_schema.tables?where?table_schema='test_user'?and?table_name='user'; +----------------+|?auto_increment?| +----------------+|??????????10000?| +----------------+1?row?in?set?(0.04?sec)

本文講解了通過MySql查看與修改auto_increment的方法,更多相關內容請關注php中文網。

相關推薦:

如何通過php生成網頁桌面的快捷方式

如何通過php生成網頁桌面的快捷方式

如何通過php生成網頁桌面的快捷方式

? 版權聲明
THE END
喜歡就支持一下吧
點贊6 分享