zoukankan      html  css  js  c++  java
  • MySql查看与修改auto_increment方法(转)

    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为 10000

    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)
  • 相关阅读:
    temp12
    temp111
    test.c
    vipLogin.c
    services.c
    request.c
    managerLogin.c
    将博客搬至CSDN
    SpringMabatis整合项目mybatis-configuration.xml核心配置
    logback-test.xml配置文件模板
  • 原文地址:https://www.cnblogs.com/ajianbeyourself/p/9098318.html
Copyright © 2011-2022 走看看