MySql查看与修改auto_increment方法
2015-12-28 22:07
811 查看
本文将介绍如何查看表的auto_increment及其修改方法
例子:查看 test_user 库的 user 表 auto_increment
例子:修改 test_user 库 user 表 auto_increment为 10000
查看表当前auto_increment
表的基本数据是存放在mysql的information_schema库的tables表中,我们可以使用sql查出。[code]select auto_increment from information_schema.tables where table_schema='db name' and table_name='table name';
例子:查看 test_user 库的 user 表 auto_increment
[code]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
[code]alter table tablename auto_increment=NUMBER;
例子:修改 test_user 库 user 表 auto_increment为 10000
[code]mysql> alter table test_user.user auto_increment=10000; Query OK, 0 rows affected (0.12 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> 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 jdbc驱动源码分析(获取Statement对象)
- mysql中timestamp,datetime,int类型的区别与优劣
- Windows下使用mysql
- [MySQL]Ubuntu下解决中文乱码问题
- mysql 字段拼接
- 整理的一些MySQL中排名查询的语句
- mysql group 陷阱
- mysql user权限表
- mysql 的 find_in_set,INSTR函数使用方法
- 连接MySQL数据库时常见故障问题的分析与解决
- JDBC_获取插入记录的主键值(基于MySQL数据库)
- Mysql分页查询获取totalCount大幅提升性能的办法总结
- MySQL对数据表进行分组查询
- mysql的查询、子查询及连接查询
- mysql分布式中间件cobar
- mysql中对数字处理的函数
- MySQL和SQLServer的比较
- Mysql优化器源码
- 得前一次MySQL操作所影响的记录行数
- 关于MySQL分页几个好的博文