如何通过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 数组元素快速去重效果

阅读剩余部分

相关阅读 >>

mysql5.6启动内存占用过高解决方案

关于mysql超长自动截断实例详解

mysql数据控制语言实例分享

mysql怎么给字符串字段加索引

mysql中error_log介绍

mysql存储过程是什么样

一文掌握mysql表的创建和约束

实例讲解sqlite迁移到mysql脚本的方法_

mysql怎么删除注册表

mysql黑框怎么改密码?mysql黑窗口怎么改密码?

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


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

数据库系统概念 第6版

机械工业出版社

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



打赏

取消

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

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

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

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

评论

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