21
21
create table t1 (id int not null auto_increment primary key, username varchar(32) not null, unique (username));
22
insert into t1 values (NULL,"mysql");
23
insert into t1 values (NULL,"mysql ab");
24
insert into t1 values (NULL,"mysql a");
25
insert into t1 values (NULL,"r1manic");
26
insert into t1 values (NULL,"r1man");
22
insert into t1 values (0,"mysql");
23
insert into t1 values (0,"mysql ab");
24
insert into t1 values (0,"mysql a");
25
insert into t1 values (0,"r1manic");
26
insert into t1 values (0,"r1man");
30
30
# Test insert syntax
33
create table t1 (a int not null auto_increment, primary key (a), t timestamp null, c char(10) default "hello", i int);
34
insert into t1 values (default,default,default,default);
35
insert into t1 values (default,default,default,default);
36
--error ER_INVALID_TIMESTAMP_VALUE # Bad timestamp
37
insert into t1 values (4,0,"a",5);
38
insert into t1 values (default,default,default,default);
39
select a,t is not null,c,i from t1;
33
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello", i int);
34
insert into t1 values (default,default,default,default), (default,default,default,default), (4,0,"a",5),(default,default,default,default);
35
select a,t>0,c,i from t1;
41
37
insert into t1 set a=default,t=default,c=default;
42
38
insert into t1 set a=default,t=default,c=default,i=default;
43
insert into t1 set a=4,t= NULL,c="a",i=5;
44
insert into t1 set a=5,t= NULL,c="a",i=null;
39
insert into t1 set a=4,t=0,c="a",i=5;
40
insert into t1 set a=5,t=0,c="a",i=null;
45
41
insert into t1 set a=default,t=default,c=default,i=default;
46
select a,t is not null,c,i from t1;
42
select a,t>0,c,i from t1;
65
61
create table t1 (email varchar(50));
66
62
insert into t1 values ('sasha@mysql.com'),('monty@mysql.com'),('foo@hotmail.com'),('foo@aol.com'),('bar@aol.com');
67
63
create table t2(id int not null auto_increment primary key, t2 varchar(50), unique(t2));
68
insert into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
64
insert delayed into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
131
125
insert into t1 SET a=1, b=a+1;
132
126
insert into t1 (a,b) select 1,2;
133
127
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
134
--error ER_FIELD_SPECIFIED_TWICE
135
129
replace into t1 (a,a) select 100, 'hundred';
136
--error ER_FIELD_SPECIFIED_TWICE
137
131
insert into t1 (a,b,b) values (1,1,1);
138
--error ER_WRONG_VALUE_COUNT_ON_ROW
139
133
insert into t1 (a,a) values (1,1,1);
140
--error ER_FIELD_SPECIFIED_TWICE
141
135
insert into t1 (a,a) values (1,1);
142
--error ER_FIELD_SPECIFIED_TWICE
143
137
insert into t1 SET a=1,b=2,a=1;
144
--error ER_FIELD_SPECIFIED_TWICE
145
139
insert into t1 (b,b) select 1,2;
146
--error ER_FIELD_SPECIFIED_TWICE
147
141
INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);