MySQL查詢和修改auto_increment的方法

來源:互聯網
上載者:User

標籤:one   一個   set   16px   alt   from   table   mysql   orm   

查詢表名為tableName的auto_increment值:複製代碼 代碼如下:SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_schema=‘photos‘ and table_name="tableName";
table_schema=‘photos‘ ----  為所在資料庫名稱,沒有這個會把root中所有表格中表格名都為tableName的auto_increment  都調出來;

information_schema.tables  為固定的格式,sql進入命令終端----進入資料庫中操作的內容;


修改 test_user 庫 user 表 auto_increment為 10000mysql> 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)

修改 photos 庫 tf_user 表 auto_increment為 20

mysql> alter table `photos`.`tf_user` auto_increment=20;
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> select auto_increment from information_schema.tables where table_schema=‘photos‘ and table_name=‘tf_user‘;
+----------------+
| auto_increment |
+----------------+
| 20 |
+----------------+
1 row in set (0.00 sec)



也可以在表格的  操作 中  查看  修改   下一個插入資料的   AUTO_INCREMENT;---這樣比較方便
http://blog.csdn.net/fdipzone/article/details/50421831

MySQL查詢和修改auto_increment的方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.