2
drop table if exists auto_incr_test,auto_incr_test2
5
Query OK, 0 rows affected
8
create table auto_incr_test (id int not null auto_increment, name char(40), timestamp timestamp, primary key (id))
11
Query OK, 0 rows affected
14
insert into auto_incr_test (name) values ("first record")
17
Query OK, 1 row affected
20
insert into auto_incr_test values (last_insert_id()+1,"second record",null)
23
Query OK, 1 row affected
26
insert into auto_incr_test (id,name) values (10,"tenth record")
29
Query OK, 1 row affected
32
insert into auto_incr_test values (0,"eleventh record",null)
35
Query OK, 1 row affected
38
insert into auto_incr_test values (last_insert_id()+1,"12","1997-01-01")
41
Query OK, 1 row affected
44
insert into auto_incr_test values (12,"this will not work",NULL)
47
ERROR 1062 at line 15: Duplicate entry '12' for key 1
49
replace into auto_incr_test values (12,"twelfth record",NULL)
52
Query OK, 2 rows affected
55
select * from auto_incr_test
59
1 first record 19980817042654
60
2 second record 19980817042655
61
10 tenth record 19980817042655
62
11 eleventh record 19980817042655
63
12 twelfth record 19980817042655
67
create table auto_incr_test2 (id int not null auto_increment, name char(40), primary key (id))
70
Query OK, 0 rows affected
73
insert into auto_incr_test2 select NULL,name from auto_incr_test
76
Query OK, 5 rows affected
77
Records: 5 Duplicates: 0 Warnings: 0
80
insert into auto_incr_test2 select id,name from auto_incr_test
83
Query OK, 3 rows affected
84
Records: 5 Duplicates: 2 Warnings: 0
87
replace into auto_incr_test2 select id,name from auto_incr_test
90
Query OK, 5 rows affected
91
Records: 5 Duplicates: 5 Warnings: 0
94
select * from auto_incr_test2
109
drop table auto_incr_test,auto_incr_test2
112
Query OK, 0 rows affected