关于修改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 Warning开发云主机域名s: 0mysql> 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: 0mysql> 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)

相关推荐: MySQL高可用方案介绍

欢迎转载,请注明作者、出处。 MySQL-Transefer(下称Transfer)是一个基于MySQL+patch后得到的主从同步工具。 其主要目的是为了解决原版本的主从同步里,从库是单线程apply主库的binlog,导致的延迟。 MySQL5.6以后的版…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

Like (0)
Donate 微信扫一扫 微信扫一扫
Previous 06/05 09:57
Next 06/05 09:57

相关推荐