📄 auto_increment.res
字号:
--------------drop table if exists auto_incr_test,auto_incr_test2--------------Query OK, 0 rows affected--------------create table auto_incr_test (id int not null auto_increment, name char(40), timestamp timestamp, primary key (id))--------------Query OK, 0 rows affected--------------insert into auto_incr_test (name) values ("first record")--------------Query OK, 1 row affected--------------insert into auto_incr_test values (last_insert_id()+1,"second record",null)--------------Query OK, 1 row affected--------------insert into auto_incr_test (id,name) values (10,"tenth record")--------------Query OK, 1 row affected--------------insert into auto_incr_test values (0,"eleventh record",null)--------------Query OK, 1 row affected--------------insert into auto_incr_test values (last_insert_id()+1,"12","1997-01-01")--------------Query OK, 1 row affected--------------insert into auto_incr_test values (12,"this will not work",NULL)--------------ERROR 1062 at line 15: Duplicate entry '12' for key 1--------------replace into auto_incr_test values (12,"twelfth record",NULL)--------------Query OK, 2 rows affected--------------select * from auto_incr_test--------------id name timestamp1 first record 199808170426542 second record 1998081704265510 tenth record 1998081704265511 eleventh record 1998081704265512 twelfth record 199808170426555 rows in set--------------create table auto_incr_test2 (id int not null auto_increment, name char(40), primary key (id))--------------Query OK, 0 rows affected--------------insert into auto_incr_test2 select NULL,name from auto_incr_test--------------Query OK, 5 rows affectedRecords: 5 Duplicates: 0 Warnings: 0--------------insert into auto_incr_test2 select id,name from auto_incr_test--------------Query OK, 3 rows affectedRecords: 5 Duplicates: 2 Warnings: 0--------------replace into auto_incr_test2 select id,name from auto_incr_test--------------Query OK, 5 rows affectedRecords: 5 Duplicates: 5 Warnings: 0--------------select * from auto_incr_test2--------------id name1 first record2 second record3 tenth record4 eleventh record5 twelfth record10 tenth record11 eleventh record12 twelfth record8 rows in set--------------drop table auto_incr_test,auto_incr_test2--------------Query OK, 0 rows affectedBye
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -