如何通过MySql查看与修改auto_increment的方

首页 编程分享 DB丨SERVICE 正文

阿斌啊 转载 编程分享 2018-04-06 20:26:52

简介 是存放在mysql的information_schema库的tables表中,我们可以使用sql查出。


本文将介绍如何查看表的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中文网。

相关推荐:



转载链接:http://www.php.cn//mysql-tutorials-402204.html


Tags:


本篇评论 —— 揽流光,涤眉霜,清露烈酒一口话苍茫。


    声明:参照站内规则,不文明言论将会删除,谢谢合作。


      最新评论




ABOUT ME

Blogger:袅袅牧童 | Arkin

Ido:PHP攻城狮

WeChat:nnmutong

Email:nnmutong@icloud.com

标签云