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


本文摘自PHP中文网,作者jacklove,侵删。

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

查看表当前auto_increment

表的基本数据是存放在mysql的information_schema库的tables表中,我们可以使用sql查出。

1

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

例子:查看 test_user 库的 user 表 auto_increment

1

2

3

4

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

1

alter table tablename auto_increment=NUMBER;

例子:修改 test_user 库 user 表 auto_increment为 10000

1

2

3

4

5

6

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生成网页桌面的快捷方式

利用js遍历获取表格内数据的方法

如何实现php 数组元素快速去重效果

阅读剩余部分

相关阅读 >>

mysql无法创建视图怎么办

mysql 出现1290错误怎么办

mysql 5.7中的关键字与保留字详解

mysql中database()和current_user()函数的示例详解

如何解决mysql8.0 没有端口的问题

mac上mysql忘记密码怎么解决?

linux centos mysql数据库安装配置实例分享

简单讲解对wordpress数据库的认识及使用命令

mysql如何找回误删除数据

如何删除mysql中的自增主键

更多相关阅读请进入《mysql》频道 >>


数据库系统概念 第6版
书籍

数据库系统概念 第6版

机械工业出版社

本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...