zoukankan      html  css  js  c++  java
  • MySql查看与改动auto_increment方法

    本文将介绍怎样查看表的auto_increment及其改动方法

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

    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)
  • 相关阅读:
    数据结构-二叉搜索树
    多任务处理方式之一:多进程
    TCP并发服务器
    REST是什么?RESTFul又是什么?这二者的关系是怎样的?
    Python中的深浅拷贝的区别
    查找算法之 '二分法查找'
    排序算法之 '快速排序'
    CCS
    CCS
    CCS
  • 原文地址:https://www.cnblogs.com/wgwyanfs/p/7190860.html
Copyright © 2011-2022 走看看