create table test2(id int(2) AUTO_INCREMENT,name varchar(10),primary ke..."/>
溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

關(guān)于修改AUTO_INCREMENT列的默認(rèn)值的測試

發(fā)布時(shí)間:2020-08-09 13:36:37 來源:ITPUB博客 閱讀:161 作者:orchidllh 欄目:MySQL數(shù)據(jù)庫

其實(shí)是個(gè)很簡單的操作,但是忽然有人問我就是想不起來,暫且做個(gè)筆記在這里。

mysql> create table test2(id int(2) AUTO_INCREMENT,name varchar(10),primary key(id));
Query OK, 0 rows affected (0.03 sec)

mysql> insert into test2 values(null,'a'),(null,'b'),(null,'c');
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> select * from test2;
+----+------+
| id | name |
+----+------+
| 1 | a |
| 2 | b |
| 3 | c |
+----+------+
3 rows in set (0.00 sec)

mysql> delete from test2 where id in (2,3);
Query OK, 2 rows affected (0.00 sec)

mysql> select * from test2;
+----+------+
| id | name |
+----+------+
| 1 | a |
+----+------+
1 row in set (0.00 sec)

mysql> insert into test2 values(null,'d');
Query OK, 1 row affected (0.00 sec)

mysql> select * from test2;
+----+------+
| id | name |
+----+------+
| 1 | a |
| 4 | d |
+----+------+
2 rows in set (0.00 sec)

mysql> delete from test2 where id = 4;
Query OK, 1 row affected (0.00 sec)

mysql> alter table test2 AUTO_INCREMENT=2;
Query OK, 1 row affected (0.02 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into test2 values(null,'f');
Query OK, 1 row affected (0.00 sec)

mysql> select * from test2;
+----+------+
| id | name |
+----+------+
| 1 | a |
| 2 | f |
+----+------+
2 rows in set (0.00 sec)

[@more@]

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI