Home > Database > Mysql Tutorial > body text

How to view and modify auto_increment method through MySql

jacklove
Release: 2018-06-09 10:00:17
Original
2008 people have browsed it

This article will introduce how to view the auto_increment of the table and how to modify it

View the current auto_increment of the table

The basic data of the table is tables stored in the information_schema library of mysql table, we can use sql to find out.

select auto_increment from information_schema.tables where table_schema='db name' and table_name='table name';
Copy after login

Example: View test_user library’s user tableauto_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)
Copy after login

Modify table auto_increment

alter table tablename auto_increment=NUMBER;
Copy after login

Example: Modify test_user library user table auto_increment to 10000

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)
Copy after login

This article explains how to view and modify auto_increment through MySql. For more related content, please pay attention to the php Chinese website.

Related recommendations:

How to generate a shortcut to the web desktop through php

Use js traversal to obtain the data in the table Method

How to achieve rapid deduplication effect of php array elements

The above is the detailed content of How to view and modify auto_increment method through MySql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template