关于修改AUTO_INCREMENT列的默认值的测试
其实是个很简单的操作,但是忽然有人问我就是想不起来,暂且做个笔记在这里。
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)
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341