add by zhj:  在创建表时,如果没有显式的指定AUTO_INCREMENT的值,那它默认是1

原文:https://blog.csdn.net/fdipzone/article/details/50421831

查看表当前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 库的 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为

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查看与修改auto_increment方法(转)的更多相关文章

  1. mysql查看和修改注释

    MySQL查看注释,MySQL修改注释,mysql查看注释,mysql修改注释 1.给大家做演示,这里随便创建一张学生表,代码如下: CREATE TABLE `student` ( `id` int ...

  2. MySQL查询和修改auto_increment的方法

    查询表名为tableName的auto_increment值: 复制代码 代码如下: SELECT AUTO_INCREMENT FROM information_schema.tables WHER ...

  3. MySQL查看和修改字符集的方法

    一.查看字符集 1.查看MYSQL数据库服务器和数据库字符集 方法一:show variables like '%character%';方法二:show variables like 'collat ...

  4. mysql查看和修改最大数量

    通常,mysql的最大连接数默认是100, 最大可以达到16384.1.查看最大连接数:show variables like '%max_connections%';2.修改最大连接数方法一:修改配 ...

  5. MySQL查看和修改字符编码

    MySQL的默认编码是Latin1,不支持中文,要支持中午需要把数据库的默认编码修改为gbk或者utf8. 1.需要以root用户身份登陆才可以查看数据库编码方式(以root用户身份登陆的命令为:&g ...

  6. MYSQL查看和修改存储引擎

    最近,公司的BBS压力越来越大,表死锁越来越严重. 在其它优化同作的情况下,MYISAM引擎转为INNODB引擎也纳入计划当中. 参考URL如下:简单,但要注意备份... ============ h ...

  7. MySQL查看和修改表的存储引擎(转载+加点东西)

    1 查看系统支持的存储引擎 show engines; 2 查看表使用的存储引擎 两种方法: a.show table status from YOUR_DB_NAME where name='YOU ...

  8. MySQL查看和修改表的存储引擎

    1 查看系统支持的存储引擎 show engines; 2 查看表使用的存储引擎 两种方法: a.show table status from db_name where name='table_na ...

  9. mysql 查看或者修改数据库密码

    首先启动命令行 1.在命令行运行:taskkill /f /im mysqld-nt.exe 下面的操作是操作mysql中bin目录下的一些程序,如果没有配置环境变量的话,需要切换到mysql的bin ...

随机推荐

  1. nginx(二)支持websocket配置

    在默认的配置nginx.conf文件中做如下配置改动 一.http域的设置 http { include mime.types; default_type application/octet-stre ...

  2. HDU 5095--Linearization of the kernel functions in SVM【模拟】

    Linearization of the kernel functions in SVM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: ...

  3. YARN Resource Management

    https://www.jianshu.com/p/b9245242472b https://stackoverflow.com/questions/42637631/what-does-virtua ...

  4. iScroll的使用

    CDN: <script src="//ossweb-img.qq.com/images/js/iscroll_library/iscroll-5.2.0.js">&l ...

  5. 在tmux会话之间共享窗口(Windows & Panes)

    去年写过一篇 从Tmux 转到GNU Screen,理由是我可以 在两个显示器上通过PuTTY连接到同一个GNU Screen会话,但两个显示器可以显示不同的窗口(用GNU Screen的术语来说,是 ...

  6. [Git] 将本地分支与远程分支关联

    . . . . . 在本地工程中添加Git,并将其与远程的空库关联起来,只需如下几步. 1. 创建空库 $ git init Initialized empty Git repository in D ...

  7. View - RemoteViews

    设计Android的工程师起名字还是挺规范的,而且一眼就知道是什么意思.RemoteViews,顾名思义,远程的View.Android为了能让进程A显示进程B的View,设计了这么一种View(其实 ...

  8. python让实例作用于for循环并当做list来使用

    python如果想让一个类被用于for....in  循环,类型list和tuple那样,可以实现__iter__方法. 这个方法返回一个迭代对象,python的for循环就会不断调用该迭代对象的ne ...

  9. node-log4js3.0.6配置

    const log4js = require('log4js'); const conf = { "appenders": { "access": { &quo ...

  10. 初学UML之-------用例图

     本文转载至:http://blog.csdn.net/a649518776/article/details/7493148 一.UML简介 UML(统一建模语言,Unified Modeling L ...