ホームページ  >  記事  >  データベース  >  MySql を通じて auto_increment メソッドを表示および変更する方法

MySql を通じて auto_increment メソッドを表示および変更する方法

jacklove
jackloveオリジナル
2018-06-09 10:00:171946ブラウズ

この記事ではテーブルの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';

例: 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;

user

テーブルauto_increment10000

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)
この記事では、表示と変更の方法について説明しますMySql による auto_increment の詳細については、php 中国語 Web サイトを参照してください。 関連する推奨事項:

phpを介してWebデスクトップへのショートカットを生成する方法

jsトラバーサルを使用してテーブル内のデータを取得する方法

php配列の迅速な重複排除効果を実現する方法要素

以上がMySql を通じて auto_increment メソッドを表示および変更する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。