怎么通過MySql查看與更改auto_increment的方法
發(fā)表時間:2023-07-11 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:18
[摘要]本文將介紹如何查看表的auto_increment及其修改方法查看表當(dāng)前auto_increment表的基本數(shù)據(jù)是存放在mysql的information_schema庫的tables表中,我們可以...
本文將介紹如何查看表的auto_increment及其修改方法
查看表當(dāng)前auto_increment
表的基本數(shù)據(jù)是存放在mysql的information_schema庫的tables表中,我們可以使用sql查出。
select auto_increment from information_schema.tables where table_schema='db name' and table_name='table name';
例子:查看 test_user 庫的 user 表 auto_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_user 庫 user 表 auto_increment為 10000
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的方法,更多相關(guān)內(nèi)容請關(guān)注php中文網(wǎng)。
相關(guān)推薦:
如何通過php生成網(wǎng)頁桌面的快捷方式
利用js遍歷獲取表格內(nèi)數(shù)據(jù)的方法
如何實(shí)現(xiàn)php 數(shù)組元素快速去重效果
以上就是如何通過MySql查看與修改auto_increment的方法的詳細(xì)內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章!
學(xué)習(xí)教程快速掌握從入門到精通的SQL知識。