1
SET SESSION STORAGE_ENGINE = MEMORY;
2
drop table if exists t1,t2,t3,t4;
3
drop database if exists mysqltest;
4
create table t1 (id int not null auto_increment, code int not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=MyISAM;
5
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
6
select id, code, name from t1 order by id;
15
update ignore t1 set id = 8, name = 'Sinisa' where id < 3;
16
select id, code, name from t1 order by id;
25
update ignore t1 set id = id + 10, name = 'Ralph' where id < 4;
26
select id, code, name from t1 order by id;
37
id int NOT NULL auto_increment,
38
parent_id int DEFAULT '0' NOT NULL,
39
level int DEFAULT '0' NOT NULL,
41
KEY parent_id (parent_id),
44
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
45
update t1 set parent_id=parent_id+100;
46
select * from t1 where parent_id=102;
51
update t1 set id=id+1000;
52
update t1 set id=1024 where id=1009;
53
Got one of the listed errors
95
update ignore t1 set id=id+1;
137
update ignore t1 set id=1023 where id=1010;
138
select * from t1 where parent_id=102;
143
explain select level from t1 where level=1;
144
id select_type table type possible_keys key key_len ref rows Extra
145
1 SIMPLE t1 ref level level 4 const # Using index
146
explain select level,id from t1 where level=1;
147
id select_type table type possible_keys key key_len ref rows Extra
148
1 SIMPLE t1 ref level level 4 const #
149
explain select level,id,parent_id from t1 where level=1;
150
id select_type table type possible_keys key key_len ref rows Extra
151
1 SIMPLE t1 ref level level 4 const #
152
select level,id from t1 where level=1;
160
select level,id,parent_id from t1 where level=1;
169
Table Op Msg_type Msg_text
170
test.t1 optimize status OK
172
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
173
t1 0 PRIMARY 1 id A # NULL NULL BTREE
174
t1 1 parent_id 1 parent_id A # NULL NULL BTREE
175
t1 1 level 1 level A # NULL NULL BTREE
178
gesuchnr int DEFAULT '0' NOT NULL,
179
benutzer_id int DEFAULT '0' NOT NULL,
180
PRIMARY KEY (gesuchnr,benutzer_id)
182
replace into t1 (gesuchnr,benutzer_id) values (2,1);
183
replace into t1 (gesuchnr,benutzer_id) values (1,1);
184
replace into t1 (gesuchnr,benutzer_id) values (1,1);
190
create table t1 (a int) engine=MyISAM;
191
insert into t1 values (1), (2);
193
Table Op Msg_type Msg_text
194
test.t1 optimize status OK
195
delete from t1 where a = 1;
200
Table Op Msg_type Msg_text
201
test.t1 check status OK
203
create table t1 (a int,b varchar(20)) engine=MyISAM;
204
insert into t1 values (1,""), (2,"testing");
205
delete from t1 where a = 1;
209
create index skr on t1 (a);
210
insert into t1 values (3,""), (4,"testing");
212
Table Op Msg_type Msg_text
213
test.t1 analyze status OK
215
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
216
t1 1 skr 1 a A # NULL NULL YES BTREE
218
create table t1 (a int,b varchar(20),key(a)) engine=MyISAM;
219
insert into t1 values (1,""), (2,"testing");
220
select * from t1 where a = 1;
225
user_id int DEFAULT '0' NOT NULL,
228
ref_email varchar(100) DEFAULT '' NOT NULL,
230
PRIMARY KEY (user_id,ref_email)
232
INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar');
233
select * from t1 where user_id=10292;
234
user_id name phone ref_email detail
235
10292 sanjeev 29153373 sansh777@hotmail.com xxx
236
10292 shirish 2333604 shirish@yahoo.com ddsds
237
10292 sonali 323232 sonali@bolly.com filmstar
238
INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds');
239
select * from t1 where user_id=10292;
240
user_id name phone ref_email detail
241
10292 sanjeev 29153373 sansh777@hotmail.com xxx
242
10292 shirish 2333604 shirish@yahoo.com ddsds
243
10292 sonali 323232 sonali@bolly.com filmstar
244
select * from t1 where user_id>=10292;
245
user_id name phone ref_email detail
246
10292 sanjeev 29153373 sansh777@hotmail.com xxx
247
10292 shirish 2333604 shirish@yahoo.com ddsds
248
10292 sonali 323232 sonali@bolly.com filmstar
249
10293 shirish 2333604 shirish@yahoo.com ddsds
250
select * from t1 where user_id>10292;
251
user_id name phone ref_email detail
252
10293 shirish 2333604 shirish@yahoo.com ddsds
253
select * from t1 where user_id<10292;
254
user_id name phone ref_email detail
255
10291 sanjeev 29153373 sansh777@hotmail.com xxx
257
CREATE TABLE t1 (a int not null, b int not null,c int not null,
258
key(a),primary key(a,b), unique(c),key(a),unique(b)) ENGINE = MyISAM;
260
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
261
t1 0 PRIMARY 1 a A # NULL NULL BTREE
262
t1 0 PRIMARY 2 b A # NULL NULL BTREE
263
t1 0 c 1 c A # NULL NULL BTREE
264
t1 0 b 1 b A # NULL NULL BTREE
265
t1 1 a 1 a A # NULL NULL BTREE
266
t1 1 a_2 1 a A # NULL NULL BTREE
268
create table t1 (col1 int not null, col2 char(4) not null, primary key(col1)) ENGINE = MEMORY;
269
alter table t1 engine=MyISAM;
270
insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
278
update t1 set col2='7' where col1='4';
286
alter table t1 add co3 int not null;
294
update t1 set col2='9' where col1='2';
303
create table t1 (a int not null , b int, primary key (a)) engine = MyISAM;
304
create table t2 (a int not null , b int, primary key (a)) engine = MEMORY;
305
insert into t1 VALUES (1,3) , (2,3), (3,3);
311
insert into t2 select * from t1;
317
delete from t1 where b = 3;
320
insert into t1 select * from t2;
333
id int NOT NULL auto_increment,
334
ggid varchar(32) binary DEFAULT '' NOT NULL,
335
email varchar(64) DEFAULT '' NOT NULL,
336
passwd varchar(32) binary DEFAULT '' NOT NULL,
340
insert into t1 (ggid,passwd) values ('test1','xxx');
341
insert into t1 (ggid,passwd) values ('test2','yyy');
342
insert into t1 (ggid,passwd) values ('test2','this will fail');
343
ERROR 23000: Duplicate entry 'test2' for key 'ggid'
344
insert into t1 (ggid,id) values ('this will fail',1);
345
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
346
select * from t1 where ggid='test1';
349
select * from t1 where passwd='xxx';
352
select * from t1 where id=2;
355
replace into t1 (ggid,id) values ('this will work',1);
356
replace into t1 (ggid,passwd) values ('test2','this will work');
357
update t1 set id=100,ggid='test2' where id=1;
358
ERROR 23000: Duplicate entry 'test2' for key 'ggid'
362
3 test2 this will work
363
select * from t1 where id=1;
366
select * from t1 where id=999;
370
user_name varchar(12),
373
user_id int DEFAULT '0' NOT NULL,
379
dummy_primary_key int NOT NULL auto_increment,
380
PRIMARY KEY (dummy_primary_key)
382
INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
383
INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
384
INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
385
INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
386
INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
387
select user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
388
user_name password subscribed user_id quota weight access_date access_time approved dummy_primary_key
389
user_0 somepassword N 0 0 0 2000-09-07 23:06:59 2000-09-07 23:06:59 1
390
user_1 somepassword Y 1 1 1 2000-09-07 23:06:59 2000-09-07 23:06:59 2
391
user_2 somepassword N 2 2 1.4142135623731 2000-09-07 23:06:59 2000-09-07 23:06:59 3
392
user_3 somepassword Y 3 3 1.7320508075689 2000-09-07 23:06:59 2000-09-07 23:06:59 4
393
user_4 somepassword N 4 4 2 2000-09-07 23:06:59 2000-09-07 23:06:59 5
396
id int NOT NULL auto_increment,
397
parent_id int DEFAULT '0' NOT NULL,
398
level int DEFAULT '0' NOT NULL,
400
KEY parent_id (parent_id),
403
INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1);
404
INSERT INTO t1 values (179,5,2);
405
update t1 set parent_id=parent_id+100;
406
select * from t1 where parent_id=102;
411
update t1 set id=id+1000;
412
update t1 set id=1024 where id=1009;
454
update ignore t1 set id=id+1;
496
update ignore t1 set id=1023 where id=1010;
497
select * from t1 where parent_id=102;
502
explain select level from t1 where level=1;
503
id select_type table type possible_keys key key_len ref rows Extra
504
1 SIMPLE t1 ref level level 4 const # Using index
505
select level,id from t1 where level=1;
513
select level,id,parent_id from t1 where level=1;
521
select level,id from t1 where level=1 order by id;
529
delete from t1 where level=1;
567
sca_code char(6) NOT NULL,
568
cat_code char(6) NOT NULL,
569
sca_desc varchar(50),
570
lan_code char(2) NOT NULL,
571
sca_pic varchar(100),
572
sca_sdesc varchar(50),
573
sca_sch_desc varchar(16),
574
PRIMARY KEY (sca_code, cat_code, lan_code),
575
INDEX sca_pic (sca_pic)
577
INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING');
578
select count(*) from t1 where sca_code = 'PD';
581
select count(*) from t1 where sca_code <= 'PD';
584
select count(*) from t1 where sca_pic is null;
587
alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
588
select count(*) from t1 where sca_code='PD' and sca_pic is null;
591
select count(*) from t1 where cat_code='E';
594
alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
595
select count(*) from t1 where sca_code='PD' and sca_pic is null;
598
select count(*) from t1 where sca_pic >= 'n';
601
select sca_pic from t1 where sca_pic is null;
605
update t1 set sca_pic="test" where sca_pic is null;
606
delete from t1 where sca_code='pd';
609
CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=MyISAM;
610
insert into t1 (a) values(1),(2),(3);
611
select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
616
select a from t1 natural join t1 as t2 where b >= @a order by a;
621
update t1 set a=5 where a=1;
628
create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=MyISAM;
629
insert into t1 values("hello",1),("world",2);
630
select * from t1 order by b desc;
635
Table Op Msg_type Msg_text
636
test.t1 optimize status OK
638
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
639
t1 0 PRIMARY 1 a A # NULL NULL BTREE
641
create table t1 (i int, j int ) ENGINE=MyISAM;
642
insert into t1 values (1,2);
643
select * from t1 where i=1 and j=2;
646
create index ax1 on t1 (i,j);
647
select * from t1 where i=1 and j=2;
656
INSERT INTO t1 VALUES (1, 1);
657
SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;
661
CREATE TABLE t1 (a int NOT NULL) engine=MyISAM;
662
INSERT INTO t1 VALUES (1);
667
create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = MyISAM;
668
insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
669
explain select * from t1 where a > 0 and a < 50;
670
id select_type table type possible_keys key key_len ref rows Extra
671
1 SIMPLE t1 system PRIMARY NULL NULL NULL #
673
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=MyISAM;
674
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
675
LOCK TABLES t1 WRITE;
676
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
677
ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
692
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=MyISAM;
693
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
694
LOCK TABLES t1 WRITE;
696
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
697
ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY'
704
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
706
select id,id3 from t1;
715
create table t1 (a char(20), unique (a(5))) engine=MyISAM;
717
create table t1 (a char(20), index (a(5))) engine=MyISAM;
718
show create table t1;
720
t1 CREATE TABLE `t1` (
725
create temporary table t1 (a int not null auto_increment, primary key(a)) engine=MyISAM;
726
insert into t1 values (NULL),(NULL),(NULL);
727
delete from t1 where a=3;
728
insert into t1 values (NULL);
734
alter table t1 add b int;
743
id int auto_increment primary key,
744
name varchar(32) not null,
749
insert into t1 values (1,'one','one value',101),
750
(2,'two','two value',102),(3,'three','three value',103);
751
replace into t1 (value,name,uid) values ('other value','two',102);
752
delete from t1 where uid=102;
753
replace into t1 (value,name,uid) values ('other value','two',102);
754
replace into t1 (value,name,uid) values ('other value','two',102);
758
6 two other value 102
759
3 three three value 103
761
create database mysqltest;
762
create table mysqltest.t1 (a int not null) engine= MyISAM;
763
insert into mysqltest.t1 values(1);
764
create table mysqltest.t2 (a int not null) engine= MEMORY;
765
insert into mysqltest.t2 values(1);
766
create table mysqltest.t3 (a int not null) engine= MEMORY;
767
insert into mysqltest.t3 values(1);
769
drop database mysqltest;
770
show tables from mysqltest;
771
ERROR 42000: Unknown database 'mysqltest'
773
create table t1 (a int not null) engine= MyISAM;
774
insert into t1 values(1),(2);
781
insert into t1 values(1),(2);
788
create table t1 (a int not null) engine= MyISAM;
789
insert into t1 values(1),(2);
791
insert into t1 values(1),(2);
797
insert into t1 values(1),(2);
802
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=MyISAM;
803
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
804
explain select * from t1 order by a;
805
id select_type table type possible_keys key key_len ref rows Extra
806
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort
807
explain select * from t1 order by b;
808
id select_type table type possible_keys key key_len ref rows Extra
809
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort
810
explain select * from t1 order by c;
811
id select_type table type possible_keys key key_len ref rows Extra
812
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort
813
explain select a from t1 order by a;
814
id select_type table type possible_keys key key_len ref rows Extra
815
1 SIMPLE t1 index NULL PRIMARY 4 NULL # Using index
816
explain select b from t1 order by b;
817
id select_type table type possible_keys key key_len ref rows Extra
818
1 SIMPLE t1 index NULL b 4 NULL # Using index
819
explain select a,b from t1 order by b;
820
id select_type table type possible_keys key key_len ref rows Extra
821
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort
822
explain select a,b from t1;
823
id select_type table type possible_keys key key_len ref rows Extra
824
1 SIMPLE t1 ALL NULL NULL NULL NULL #
825
explain select a,b,c from t1;
826
id select_type table type possible_keys key key_len ref rows Extra
827
1 SIMPLE t1 ALL NULL NULL NULL NULL #
829
create table t1 (t int not null default 1, key (t)) engine=MyISAM;
831
Field Type Null Key Default Extra
835
number bigint NOT NULL default '0',
836
cname char(15) NOT NULL default '',
837
carrier_id int NOT NULL default '0',
838
privacy int NOT NULL default '0',
839
last_mod_date timestamp NOT NULL,
840
last_mod_id int NOT NULL default '0',
841
last_app_date timestamp NOT NULL,
842
last_app_id int default '-1',
843
version int NOT NULL default '0',
844
assigned_scps int default '0',
845
status int default '0'
847
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
848
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
849
INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
850
INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
851
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
852
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
854
number bigint NOT NULL default '0',
855
cname char(15) NOT NULL default '',
856
carrier_id int NOT NULL default '0',
857
privacy int NOT NULL default '0',
858
last_mod_date timestamp NOT NULL,
859
last_mod_id int NOT NULL default '0',
860
last_app_date timestamp NOT NULL,
861
last_app_id int default '-1',
862
version int NOT NULL default '0',
863
assigned_scps int default '0',
864
status int default '0'
866
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
867
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
868
INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
869
INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
871
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
872
4077711111 SeanWheeler 90 2 2002-01-11 11:28:46 500 0000-00-00 00:00:00 -1 2 3 1
873
9197722223 berry 90 3 2002-01-11 11:28:09 500 2002-01-02 11:45:32 501 4 10 0
874
650 San Francisco 0 0 2001-12-27 11:13:36 342 0000-00-00 00:00:00 -1 1 24 1
875
302467 Sue's Subshop 90 3 2002-01-09 11:32:41 500 2002-01-02 11:51:11 501 7 24 0
876
6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0
877
333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0
879
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
880
4077711111 SeanWheeler 0 2 2002-01-11 11:28:53 500 0000-00-00 00:00:00 -1 2 3 1
881
9197722223 berry 90 3 2002-01-11 11:28:18 500 2002-01-02 11:45:32 501 4 10 0
882
650 San Francisco 90 0 2002-01-09 11:31:58 342 0000-00-00 00:00:00 -1 1 24 1
883
333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0
884
delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or (t1.carrier_id=90 and t2.number is null);
886
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
887
6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0
888
333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0
890
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
891
333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0
893
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
894
333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0
896
create table t1 (id int not null auto_increment, code int not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=MyISAM;
898
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
899
SELECT @@tx_isolation,@@global.tx_isolation;
900
@@tx_isolation @@global.tx_isolation
901
SERIALIZABLE REPEATABLE-READ
902
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
903
select id, code, name from t1 order by id;
910
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
911
insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
912
select id, code, name from t1 order by id;
921
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
922
insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
923
select id, code, name from t1 order by id;
934
create table t1 (n int, d int) engine=MyISAM;
935
create table t2 (n int, d int) engine=MyISAM;
936
insert into t1 values(1,1),(1,2);
937
insert into t2 values(1,10),(2,20);
938
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
948
create table t1 (a int, b int) engine=MyISAM;
949
insert into t1 values(20,null);
950
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
952
b ifnull(t2.b,"this is null")
954
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
955
t2.b=t3.a order by 1;
956
b ifnull(t2.b,"this is null")
958
insert into t1 values(10,null);
959
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
960
t2.b=t3.a order by 1;
961
b ifnull(t2.b,"this is null")
965
create table t1 (a varchar(10) not null) engine = MEMORY;
966
create table t2 (b varchar(10) not null unique) engine=MyISAM;
967
select t1.a from t1,t2 where t1.a=t2.b;
970
create table t1 (a int not null, b int, primary key (a)) engine = MyISAM;
971
create table t2 (a int not null, b int, primary key (a)) engine = MyISAM;
972
insert into t1 values (10, 20);
973
insert into t2 values (10, 20);
974
update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
976
CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=MyISAM;
977
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
978
UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
991
CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=MyISAM;
992
CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=MyISAM;
993
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12);
994
INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
995
update t1,t2 set t1.a=t1.a+100;
1010
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
1025
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
1040
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
1067
CREATE TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=MEMORY;
1068
CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=MyISAM;
1070
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
1071
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
1074
Warning 1196 Some non-transactional changed tables couldn't be rolled back
1079
create table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) engine = MyISAM;
1080
insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2);
1081
select distinct parent,child from t1 order by parent;
1088
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=MyISAM;
1089
create table t2 (a int not null auto_increment primary key, b int) ENGINE = MEMORY;
1090
insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
1091
insert into t2 (a) select b from t1;
1092
insert into t1 (b) select b from t2;
1093
insert into t2 (a) select b from t1;
1094
insert into t1 (a) select b from t2;
1095
insert into t2 (a) select b from t1;
1096
insert into t1 (a) select b from t2;
1097
insert into t2 (a) select b from t1;
1098
insert into t1 (a) select b from t2;
1099
insert into t2 (a) select b from t1;
1100
insert into t1 (a) select b from t2;
1101
insert into t2 (a) select b from t1;
1102
insert into t1 (a) select b from t2;
1103
insert into t2 (a) select b from t1;
1104
insert into t1 (a) select b from t2;
1105
insert into t2 (a) select b from t1;
1106
insert into t1 (a) select b from t2;
1107
insert into t2 (a) select b from t1;
1108
insert into t1 (a) select b from t2;
1109
select count(*) from t1;
1112
explain select * from t1 where c between 1 and 2500;
1113
id select_type table type possible_keys key key_len ref rows Extra
1114
1 SIMPLE t1 range c c 5 NULL # Using where; Using MRR
1116
explain select * from t1 where c between 1 and 2500;
1117
id select_type table type possible_keys key key_len ref rows Extra
1118
1 SIMPLE t1 range c c 5 NULL # Using where; Using MRR
1120
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=MyISAM;
1121
insert into t1 (id) values (null),(null),(null),(null),(null);
1122
update t1 set fk=69 where fk is null order by id limit 1;
1131
create table t1 (a int not null, b int not null, key (a)) engine=MyISAM;
1132
insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
1134
update t1 set b=(@tmp:=@tmp+1) order by a;
1135
update t1 set b=99 where a=1 order by b asc limit 1;
1136
update t1 set b=100 where a=1 order by b desc limit 2;
1137
update t1 set a=a+10+b where a=1 order by b;
1138
select * from t1 order by a,b;
1153
create table t1 ( c char(8) not null ) engine=MyISAM;
1154
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
1155
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
1156
alter table t1 add b char(8) not null;
1157
alter table t1 add a char(8) not null;
1158
alter table t1 add primary key (a,b,c);
1159
update t1 set a=c, b=c;
1160
create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=MyISAM;
1161
insert into t2 select * from t1;
1162
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
1165
create table t1 (a integer auto_increment primary key) engine=MyISAM;
1166
insert into t1 (a) values (NULL),(NULL);
1168
insert into t1 (a) values (NULL),(NULL);
1174
CREATE TABLE t1 (col1 int)ENGINE=MyISAM;
1175
CREATE TABLE t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
1176
(stamp))ENGINE=MyISAM;
1177
insert into t1 values (1),(2),(3);
1178
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
1179
ERROR 22007: Incorrect datetime value: '20020204310000' for column 'stamp' at row 3
1180
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
1181
'20020204120000' GROUP BY col1;
1188
`id` int NOT NULL auto_increment,
1189
`id_object` int default '0',
1190
`id_version` int NOT NULL default '1',
1191
`label` varchar(100) NOT NULL default '',
1194
KEY `id_object` (`id_object`),
1195
KEY `id_version` (`id_version`)
1197
INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
1199
`id` int NOT NULL auto_increment,
1200
`id_version` int NOT NULL default '1',
1202
KEY `id_version` (`id_version`)
1204
INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
1205
SELECT t2.id, t1.`label` FROM t2 INNER JOIN
1206
(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl
1207
ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
1214
3525 Fournisseur Test
1216
create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=MyISAM;
1217
create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=MyISAM;
1218
create table t3 (a int, b varchar(200), c varchar(200) not null) checksum=1 engine=MEMORY;
1219
create table t4 (a int, b varchar(200), c varchar(200) not null) checksum=0 engine=MEMORY;
1220
create table t5 (a int, b varchar(200), c text not null) checksum=1 engine=MyISAM;
1221
create table t6 (a int, b varchar(200), c text not null) checksum=0 engine=MyISAM;
1222
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
1223
insert t2 select * from t1;
1224
insert t3 select * from t1;
1225
insert t4 select * from t1;
1226
insert t5 select * from t1;
1227
insert t6 select * from t1;
1228
checksum table t1, t2, t3, t4, t5, t6, t7 quick;
1238
Error 1146 Table 'test.t7' doesn't exist
1239
checksum table t1, t2, t3, t4, t5, t6, t7;
1249
Error 1146 Table 'test.t7' doesn't exist
1250
checksum table t1, t2, t3, t4, t5, t6, t7 extended;
1260
Error 1146 Table 'test.t7' doesn't exist
1261
drop table t1,t2,t3, t4, t5, t6;
1262
create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=MyISAM;
1263
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
1264
select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1;
1276
create table t1 (a int) engine=MyISAM;
1277
create table t2 like t1;
1278
show create table t2;
1280
t2 CREATE TABLE `t2` (
1285
show status like "binlog_cache_use";
1288
show status like "binlog_cache_disk_use";
1290
Binlog_cache_disk_use 0
1291
create table t1 (a int) engine=MyISAM;
1292
show status like "binlog_cache_use";
1295
show status like "binlog_cache_disk_use";
1297
Binlog_cache_disk_use 0
1301
show status like "binlog_cache_use";
1304
show status like "binlog_cache_disk_use";
1306
Binlog_cache_disk_use 0
1308
create table t1 (c char(10), index (c,c)) engine=MyISAM;
1309
ERROR 42S21: Duplicate column name 'c'
1310
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=MyISAM;
1311
ERROR 42S21: Duplicate column name 'c1'
1312
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=MyISAM;
1313
ERROR 42S21: Duplicate column name 'c1'
1314
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=MyISAM;
1315
ERROR 42S21: Duplicate column name 'c1'
1316
create table t1 (c1 char(10), c2 char(10)) engine=MyISAM;
1317
alter table t1 add key (c1,c1);
1318
ERROR 42S21: Duplicate column name 'c1'
1319
alter table t1 add key (c2,c1,c1);
1320
ERROR 42S21: Duplicate column name 'c1'
1321
alter table t1 add key (c1,c2,c1);
1322
ERROR 42S21: Duplicate column name 'c1'
1323
alter table t1 add key (c1,c1,c2);
1324
ERROR 42S21: Duplicate column name 'c1'
1326
create table t1(a int, b int) engine=MyISAM;
1327
insert into t1 values ('1111', '3333');
1328
select distinct concat(a, b) from t1;
1332
create temporary table t1 (a int) engine=MyISAM;
1333
insert into t1 values (4711);
1335
insert into t1 values (42);
1340
create table t1 (a int) engine=MyISAM;
1341
insert into t1 values (4711);
1343
insert into t1 values (42);
1348
create table t1 (a int not null, b int not null, c blob not null, d int not null, e int, primary key (a,b,c(255),d)) engine=MyISAM;
1349
insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3);
1350
select * from t1 order by a,b,c,d;
1355
explain select * from t1 order by a,b,c,d;
1356
id select_type table type possible_keys key key_len ref rows Extra
1357
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
1359
create table t1 (a char(1), b char(1), key(a, b)) engine=MyISAM;
1360
insert into t1 values ('8', '6'), ('4', '7');
1361
select min(a) from t1;
1364
select min(b) from t1 where a='8';
1368
create table t1 (x bigint not null primary key) engine=MyISAM;
1369
insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
1370
ERROR 22003: Out of range value for column 'x' at row 1
1373
select count(*) from t1 where x>0;
1376
select count(*) from t1 where x=0;
1379
select count(*) from t1 where x<0;
1382
select count(*) from t1 where x < -16;
1385
select count(*) from t1 where x = -16;
1388
explain select count(*) from t1 where x > -16;
1389
id select_type table type possible_keys key key_len ref rows Extra
1390
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
1391
select count(*) from t1 where x > -16;
1394
select * from t1 where x > -16;
1396
select count(*) from t1 where x = 18446744073709551601;
1400
set storage_engine=MyISAM;
1401
drop table if exists t1,t2,t3;
1402
--- Testing varchar ---
1403
--- Testing varchar ---
1404
create table t1 (v varchar(10), c char(10), t text);
1405
insert into t1 values('+ ', '+ ', '+ ');
1406
set @a=repeat(' ',20);
1407
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1409
Note 1265 Data truncated for column 'v' at row 1
1410
Note 1265 Data truncated for column 'c' at row 1
1411
select concat('*',v,'*',c,'*',t,'*') from t1;
1412
concat('*',v,'*',c,'*',t,'*')
1415
show create table t1;
1417
t1 CREATE TABLE `t1` (
1422
create table t2 like t1;
1423
show create table t2;
1425
t2 CREATE TABLE `t2` (
1430
create table t3 select * from t1;
1431
show create table t3;
1433
t3 CREATE TABLE `t3` (
1438
alter table t1 modify c varchar(10);
1439
show create table t1;
1441
t1 CREATE TABLE `t1` (
1446
alter table t1 modify v char(10);
1447
show create table t1;
1449
t1 CREATE TABLE `t1` (
1454
alter table t1 modify t varchar(10);
1456
Note 1265 Data truncated for column 't' at row 2
1457
show create table t1;
1459
t1 CREATE TABLE `t1` (
1464
select concat('*',v,'*',c,'*',t,'*') from t1;
1465
concat('*',v,'*',c,'*',t,'*')
1468
drop table t1,t2,t3;
1469
create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
1470
show create table t1;
1472
t1 CREATE TABLE `t1` (
1480
select count(*) from t1;
1483
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
1484
select count(*) from t1 where v='a';
1487
select count(*) from t1 where c='a';
1490
select count(*) from t1 where t='a';
1493
select count(*) from t1 where v='a ';
1496
select count(*) from t1 where c='a ';
1499
select count(*) from t1 where t='a ';
1502
select count(*) from t1 where v between 'a' and 'a ';
1505
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1508
select count(*) from t1 where v like 'a%';
1511
select count(*) from t1 where c like 'a%';
1514
select count(*) from t1 where t like 'a%';
1517
select count(*) from t1 where v like 'a %';
1520
explain select count(*) from t1 where v='a ';
1521
id select_type table type possible_keys key key_len ref rows Extra
1522
1 SIMPLE t1 ref v v 43 const # Using where; Using index
1523
explain select count(*) from t1 where c='a ';
1524
id select_type table type possible_keys key key_len ref rows Extra
1525
1 SIMPLE t1 ref c c 43 const # Using where; Using index
1526
explain select count(*) from t1 where t='a ';
1527
id select_type table type possible_keys key key_len ref rows Extra
1528
1 SIMPLE t1 ref t t 43 const # Using where
1529
explain select count(*) from t1 where v like 'a%';
1530
id select_type table type possible_keys key key_len ref rows Extra
1531
1 SIMPLE t1 range v v 43 NULL # Using where; Using index
1532
explain select count(*) from t1 where v between 'a' and 'a ';
1533
id select_type table type possible_keys key key_len ref rows Extra
1534
1 SIMPLE t1 ref v v 43 const # Using where; Using index
1535
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1536
id select_type table type possible_keys key key_len ref rows Extra
1537
1 SIMPLE t1 ref v v 43 const # Using where; Using index
1538
alter table t1 add unique(v);
1539
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1540
alter table t1 add key(v);
1541
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
1553
explain select * from t1 where v='a';
1554
id select_type table type possible_keys key key_len ref rows Extra
1555
1 SIMPLE t1 ref v,v_2 # 43 const # Using where
1556
select v,count(*) from t1 group by v limit 10;
1568
select v,count(t) from t1 group by v limit 10;
1580
select v,count(c) from t1 group by v limit 10;
1592
select sql_big_result v,count(t) from t1 group by v limit 10;
1604
select sql_big_result v,count(c) from t1 group by v limit 10;
1616
select c,count(*) from t1 group by c limit 10;
1628
select c,count(t) from t1 group by c limit 10;
1640
select sql_big_result c,count(t) from t1 group by c limit 10;
1652
select t,count(*) from t1 group by t limit 10;
1664
select t,count(t) from t1 group by t limit 10;
1676
select sql_big_result t,count(t) from t1 group by t limit 10;
1688
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
1689
show create table t1;
1691
t1 CREATE TABLE `t1` (
1699
select count(*) from t1 where v='a';
1702
select count(*) from t1 where v='a ';
1705
select count(*) from t1 where v between 'a' and 'a ';
1708
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1711
select count(*) from t1 where v like 'a%';
1714
select count(*) from t1 where v like 'a %';
1717
explain select count(*) from t1 where v='a ';
1718
id select_type table type possible_keys key key_len ref rows Extra
1719
1 SIMPLE t1 ref v v 1203 const # Using where; Using index
1720
explain select count(*) from t1 where v like 'a%';
1721
id select_type table type possible_keys key key_len ref rows Extra
1722
1 SIMPLE t1 range v v 1203 NULL # Using where; Using index
1723
explain select count(*) from t1 where v between 'a' and 'a ';
1724
id select_type table type possible_keys key key_len ref rows Extra
1725
1 SIMPLE t1 ref v v 1203 const # Using where; Using index
1726
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1727
id select_type table type possible_keys key key_len ref rows Extra
1728
1 SIMPLE t1 ref v v 1203 const # Using where; Using index
1729
explain select * from t1 where v='a';
1730
id select_type table type possible_keys key key_len ref rows Extra
1731
1 SIMPLE t1 ref v v 1203 const # Using where
1732
select v,count(*) from t1 group by v limit 10;
1744
select v,count(t) from t1 group by v limit 10;
1756
select sql_big_result v,count(t) from t1 group by v limit 10;
1768
alter table t1 drop key v, add key v (v(30));
1769
show create table t1;
1771
t1 CREATE TABLE `t1` (
1779
select count(*) from t1 where v='a';
1782
select count(*) from t1 where v='a ';
1785
select count(*) from t1 where v between 'a' and 'a ';
1788
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1791
select count(*) from t1 where v like 'a%';
1794
select count(*) from t1 where v like 'a %';
1797
explain select count(*) from t1 where v='a ';
1798
id select_type table type possible_keys key key_len ref rows Extra
1799
1 SIMPLE t1 ref v v 123 const # Using where
1800
explain select count(*) from t1 where v like 'a%';
1801
id select_type table type possible_keys key key_len ref rows Extra
1802
1 SIMPLE t1 range v v 123 NULL # Using where
1803
explain select count(*) from t1 where v between 'a' and 'a ';
1804
id select_type table type possible_keys key key_len ref rows Extra
1805
1 SIMPLE t1 ref v v 123 const # Using where
1806
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1807
id select_type table type possible_keys key key_len ref rows Extra
1808
1 SIMPLE t1 ref v v 123 const # Using where
1809
explain select * from t1 where v='a';
1810
id select_type table type possible_keys key key_len ref rows Extra
1811
1 SIMPLE t1 ref v v 123 const # Using where
1812
select v,count(*) from t1 group by v limit 10;
1824
select v,count(t) from t1 group by v limit 10;
1836
select sql_big_result v,count(t) from t1 group by v limit 10;
1848
alter table t1 modify v varchar(600), drop key v, add key v (v);
1850
Warning 1071 Specified key was too long; max key length is 1332 bytes
1851
Warning 1071 Specified key was too long; max key length is 1332 bytes
1852
Warning 1071 Specified key was too long; max key length is 1332 bytes
1853
show create table t1;
1855
t1 CREATE TABLE `t1` (
1863
select v,count(*) from t1 group by v limit 10;
1875
select v,count(t) from t1 group by v limit 10;
1887
select sql_big_result v,count(t) from t1 group by v limit 10;
1900
create table t1 (a char(10), unique (a));
1901
insert into t1 values ('a ');
1902
insert into t1 values ('a ');
1903
ERROR 23000: Duplicate entry 'a ' for key 'a'
1904
alter table t1 modify a varchar(10);
1905
insert into t1 values ('a '),('a '),('a '),('a ');
1906
ERROR 23000: Duplicate entry 'a ' for key 'a'
1907
insert into t1 values ('a ');
1908
ERROR 23000: Duplicate entry 'a ' for key 'a'
1909
insert into t1 values ('a ');
1910
ERROR 23000: Duplicate entry 'a ' for key 'a'
1911
insert into t1 values ('a ');
1912
ERROR 23000: Duplicate entry 'a ' for key 'a'
1913
update t1 set a='a ' where a like 'a%';
1914
select concat(a,'.') from t1;
1917
update t1 set a='abc ' where a like 'a ';
1918
select concat(a,'.') from t1;
1921
update t1 set a='a ' where a like 'a %';
1922
select concat(a,'.') from t1;
1925
update t1 set a='a ' where a like 'a ';
1926
select concat(a,'.') from t1;
1930
create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
1931
show create table t1;
1933
t1 CREATE TABLE `t1` (
1942
create table t1 (v char(10));
1943
show create table t1;
1945
t1 CREATE TABLE `t1` (
1949
create table t1 (v varchar(10), c char(10)) row_format=fixed;
1950
show create table t1;
1952
t1 CREATE TABLE `t1` (
1955
) ENGINE=MyISAM ROW_FORMAT=FIXED
1956
insert into t1 values('a','a'),('a ','a ');
1957
select concat('*',v,'*',c,'*') from t1;
1958
concat('*',v,'*',c,'*')
1962
create table t1(a int, b varchar(12), key ba(b, a));
1963
insert into t1 values (1, 'A'), (20, NULL);
1964
explain select * from t1 where a=20 and b is null;
1965
id select_type table type possible_keys key key_len ref rows Extra
1966
1 SIMPLE t1 ref ba ba 56 const,const 1 Using where; Using index
1967
select * from t1 where a=20 and b is null;
1971
create table t1 (a char(1), b char(1), key(a, b)) engine=MyISAM;
1972
insert into t1 values ('8', '6'), ('4', '7');
1973
select min(a) from t1;
1976
select min(b) from t1 where a='8';
1980
CREATE TABLE t1 ( `a` int NOT NULL auto_increment, `b` int default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=MyISAM;
1981
insert into t1 (b) values (1);
1982
replace into t1 (b) values (2), (1), (3);
1989
insert into t1 (b) values (1);
1990
replace into t1 (b) values (2);
1991
replace into t1 (b) values (1);
1992
replace into t1 (b) values (3);
1999
create table t1 (rowid int not null auto_increment, val int not null,primary
2000
key (rowid), unique(val)) engine=MyISAM;
2001
replace into t1 (val) values ('1'),('2');
2002
replace into t1 (val) values ('1'),('2');
2003
insert into t1 (val) values ('1'),('2');
2004
ERROR 23000: Duplicate entry '1' for key 'val'
2010
CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=MyISAM;
2011
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
2012
SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
2015
SELECT GRADE FROM t1 WHERE GRADE= 151;
2019
create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=MyISAM;
2020
create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=MyISAM;
2021
insert into t2 values ('aa','cc');
2022
insert into t1 values ('aa','bb'),('aa','cc');
2023
delete t1 from t1,t2 where f1=f3 and f4='cc';
2027
create table t1(a date) engine=MyISAM;
2028
create table t2(a date, key(a)) engine=MyISAM;
2029
insert into t1 values('2005-10-01');
2030
insert into t2 values('2005-10-01');
2031
select * from t1, t2
2032
where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
2034
2005-10-01 2005-10-01
2036
create table t1 (id int not null, f_id int not null, f int not null,
2037
primary key(f_id, id)) engine=MyISAM;
2038
create table t2 (id int not null,s_id int not null,s varchar(200),
2039
primary key(id)) engine=MyISAM;
2040
INSERT INTO t1 VALUES (8, 1, 3);
2041
INSERT INTO t1 VALUES (1, 2, 1);
2042
INSERT INTO t2 VALUES (1, 0, '');
2043
INSERT INTO t2 VALUES (8, 1, '');
2045
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
2046
WHERE mm.id IS NULL;
2047
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
2048
where mm.id is null lock in share mode;
2051
create table t1(a int not null, b int, primary key(a)) engine=MyISAM;
2052
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
2055
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2056
update t1 set b = 5 where b = 1;
2058
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2059
select * from t1 where a = 7 and b = 3 for update;
2065
CREATE TABLE t1 ( a int ) ENGINE=MyISAM;
2067
INSERT INTO t1 VALUES (1);
2069
Table Op Msg_type Msg_text
2070
test.t1 optimize status OK