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 unsigned not null auto_increment, code tinyint unsigned 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(11) NOT NULL auto_increment,
38
parent_id int(11) DEFAULT '0' NOT NULL,
39
level tinyint(4) 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 1 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 1 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 1 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(11) DEFAULT '0' NOT NULL,
179
benutzer_id int(11) 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(10) 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(11) 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(11) DEFAULT '0' NOT NULL,
379
dummy_primary_key int(11) 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(11) NOT NULL auto_increment,
397
parent_id int(11) DEFAULT '0' NOT NULL,
398
level tinyint(4) 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 1 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;
652
a int3 unsigned NOT NULL,
653
b int1 unsigned NOT NULL,
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 unsigned 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` (
721
`a` char(20) DEFAULT NULL,
723
) ENGINE=MyISAM DEFAULT CHARSET=latin1
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);
752
replace into t1 (value,name,uid) values ('other value','two',102);
753
delete from t1 where uid=102;
755
replace into t1 (value,name,uid) values ('other value','two',102);
757
replace into t1 (value,name,uid) values ('other value','two',102);
761
3 three three value 103
762
6 two other value 102
764
create database mysqltest;
765
create table mysqltest.t1 (a int not null) engine= MyISAM;
766
insert into mysqltest.t1 values(1);
767
create table mysqltest.t2 (a int not null) engine= MEMORY;
768
insert into mysqltest.t2 values(1);
769
create table mysqltest.t3 (a int not null) engine= MEMORY;
770
insert into mysqltest.t3 values(1);
772
drop database mysqltest;
773
show tables from mysqltest;
774
ERROR 42000: Unknown database 'mysqltest'
776
create table t1 (a int not null) engine= MyISAM;
777
insert into t1 values(1),(2);
784
insert into t1 values(1),(2);
791
create table t1 (a int not null) engine= MyISAM;
792
insert into t1 values(1),(2);
794
insert into t1 values(1),(2);
800
insert into t1 values(1),(2);
805
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=MyISAM;
806
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
807
explain select * from t1 order by a;
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 b;
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 * from t1 order by c;
814
id select_type table type possible_keys key key_len ref rows Extra
815
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort
816
explain select a from t1 order by a;
817
id select_type table type possible_keys key key_len ref rows Extra
818
1 SIMPLE t1 index NULL PRIMARY 4 NULL # Using index
819
explain select b from t1 order by b;
820
id select_type table type possible_keys key key_len ref rows Extra
821
1 SIMPLE t1 index NULL b 4 NULL # Using index
822
explain select a,b from t1 order by b;
823
id select_type table type possible_keys key key_len ref rows Extra
824
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort
825
explain select a,b 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 #
828
explain select a,b,c from t1;
829
id select_type table type possible_keys key key_len ref rows Extra
830
1 SIMPLE t1 ALL NULL NULL NULL NULL #
832
create table t1 (t int not null default 1, key (t)) engine=MyISAM;
834
Field Type Null Key Default Extra
838
number bigint(20) NOT NULL default '0',
839
cname char(15) NOT NULL default '',
840
carrier_id smallint(6) NOT NULL default '0',
841
privacy tinyint(4) NOT NULL default '0',
842
last_mod_date timestamp NOT NULL,
843
last_mod_id smallint(6) NOT NULL default '0',
844
last_app_date timestamp NOT NULL,
845
last_app_id smallint(6) default '-1',
846
version smallint(6) NOT NULL default '0',
847
assigned_scps int(11) default '0',
848
status tinyint(4) default '0'
850
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
851
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
852
INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
853
INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
854
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
855
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
857
number bigint(20) NOT NULL default '0',
858
cname char(15) NOT NULL default '',
859
carrier_id smallint(6) NOT NULL default '0',
860
privacy tinyint(4) NOT NULL default '0',
861
last_mod_date timestamp NOT NULL,
862
last_mod_id smallint(6) NOT NULL default '0',
863
last_app_date timestamp NOT NULL,
864
last_app_id smallint(6) default '-1',
865
version smallint(6) NOT NULL default '0',
866
assigned_scps int(11) default '0',
867
status tinyint(4) default '0'
869
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
870
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
871
INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
872
INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
874
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
875
4077711111 SeanWheeler 90 2 2002-01-11 11:28:46 500 0000-00-00 00:00:00 -1 2 3 1
876
9197722223 berry 90 3 2002-01-11 11:28:09 500 2002-01-02 11:45:32 501 4 10 0
877
650 San Francisco 0 0 2001-12-27 11:13:36 342 0000-00-00 00:00:00 -1 1 24 1
878
302467 Sue's Subshop 90 3 2002-01-09 11:32:41 500 2002-01-02 11:51:11 501 7 24 0
879
6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0
880
333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0
882
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
883
4077711111 SeanWheeler 0 2 2002-01-11 11:28:53 500 0000-00-00 00:00:00 -1 2 3 1
884
9197722223 berry 90 3 2002-01-11 11:28:18 500 2002-01-02 11:45:32 501 4 10 0
885
650 San Francisco 90 0 2002-01-09 11:31:58 342 0000-00-00 00:00:00 -1 1 24 1
886
333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0
887
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);
889
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
890
6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0
891
333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 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
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
897
333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0
899
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=MyISAM;
901
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
902
SELECT @@tx_isolation,@@global.tx_isolation;
903
@@tx_isolation @@global.tx_isolation
904
SERIALIZABLE REPEATABLE-READ
905
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
906
select id, code, name from t1 order by id;
913
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
914
insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
915
select id, code, name from t1 order by id;
924
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
925
insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
926
select id, code, name from t1 order by id;
937
create table t1 (n int(10), d int(10)) engine=MyISAM;
938
create table t2 (n int(10), d int(10)) engine=MyISAM;
939
insert into t1 values(1,1),(1,2);
940
insert into t2 values(1,10),(2,20);
941
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
951
create table t1 (a int, b int) engine=MyISAM;
952
insert into t1 values(20,null);
953
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
955
b ifnull(t2.b,"this is null")
957
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
958
t2.b=t3.a order by 1;
959
b ifnull(t2.b,"this is null")
961
insert into t1 values(10,null);
962
select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on
963
t2.b=t3.a order by 1;
964
b ifnull(t2.b,"this is null")
968
create table t1 (a varchar(10) not null) engine = MEMORY;
969
create table t2 (b varchar(10) not null unique) engine=MyISAM;
970
select t1.a from t1,t2 where t1.a=t2.b;
973
create table t1 (a int not null, b int, primary key (a)) engine = MyISAM;
974
create table t2 (a int not null, b int, primary key (a)) engine = MyISAM;
975
insert into t1 values (10, 20);
976
insert into t2 values (10, 20);
977
update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
979
CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=MyISAM;
980
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
981
UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
994
CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=MyISAM;
995
CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=MyISAM;
996
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);
997
INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
998
update t1,t2 set t1.a=t1.a+100;
1013
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
1028
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
1043
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;
1070
CREATE TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=MEMORY;
1071
CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=MyISAM;
1073
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
1074
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
1077
Warning 1196 Some non-transactional changed tables couldn't be rolled back
1082
create table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) engine = MyISAM;
1083
insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2);
1084
select distinct parent,child from t1 order by parent;
1091
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=MyISAM;
1092
create table t2 (a int not null auto_increment primary key, b int) ENGINE = MEMORY;
1093
insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
1094
insert into t2 (a) select b from t1;
1095
insert into t1 (b) select b from t2;
1096
insert into t2 (a) select b from t1;
1097
insert into t1 (a) select b from t2;
1098
insert into t2 (a) select b from t1;
1099
insert into t1 (a) select b from t2;
1100
insert into t2 (a) select b from t1;
1101
insert into t1 (a) select b from t2;
1102
insert into t2 (a) select b from t1;
1103
insert into t1 (a) select b from t2;
1104
insert into t2 (a) select b from t1;
1105
insert into t1 (a) select b from t2;
1106
insert into t2 (a) select b from t1;
1107
insert into t1 (a) select b from t2;
1108
insert into t2 (a) select b from t1;
1109
insert into t1 (a) select b from t2;
1110
insert into t2 (a) select b from t1;
1111
insert into t1 (a) select b from t2;
1112
select count(*) from t1;
1115
explain select * from t1 where c between 1 and 2500;
1116
id select_type table type possible_keys key key_len ref rows Extra
1117
1 SIMPLE t1 range c c 5 NULL # Using index condition; Using MRR
1119
explain select * from t1 where c between 1 and 2500;
1120
id select_type table type possible_keys key key_len ref rows Extra
1121
1 SIMPLE t1 range c c 5 NULL # Using index condition; Using MRR
1123
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=MyISAM;
1124
insert into t1 (id) values (null),(null),(null),(null),(null);
1125
update t1 set fk=69 where fk is null order by id limit 1;
1134
create table t1 (a int not null, b int not null, key (a)) engine=MyISAM;
1135
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);
1137
update t1 set b=(@tmp:=@tmp+1) order by a;
1138
update t1 set b=99 where a=1 order by b asc limit 1;
1139
update t1 set b=100 where a=1 order by b desc limit 2;
1140
update t1 set a=a+10+b where a=1 order by b;
1141
select * from t1 order by a,b;
1156
create table t1 ( c char(8) not null ) engine=MyISAM;
1157
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
1158
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
1159
alter table t1 add b char(8) not null;
1160
alter table t1 add a char(8) not null;
1161
alter table t1 add primary key (a,b,c);
1162
update t1 set a=c, b=c;
1163
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;
1164
insert into t2 select * from t1;
1165
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
1168
create table t1 (a integer auto_increment primary key) engine=MyISAM;
1169
insert into t1 (a) values (NULL),(NULL);
1171
insert into t1 (a) values (NULL),(NULL);
1177
CREATE TABLE t1 (col1 int(1))ENGINE=MyISAM;
1178
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
1179
(stamp))ENGINE=MyISAM;
1180
insert into t1 values (1),(2),(3);
1181
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
1183
Warning 1265 Data truncated for column 'stamp' at row 3
1184
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
1185
'20020204120000' GROUP BY col1;
1193
`id` int(10) unsigned NOT NULL auto_increment,
1194
`id_object` int(10) unsigned default '0',
1195
`id_version` int(10) unsigned NOT NULL default '1',
1196
`label` varchar(100) NOT NULL default '',
1199
KEY `id_object` (`id_object`),
1200
KEY `id_version` (`id_version`)
1202
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);
1204
`id` int(10) unsigned NOT NULL auto_increment,
1205
`id_version` int(10) unsigned NOT NULL default '1',
1207
KEY `id_version` (`id_version`)
1209
INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
1210
SELECT t2.id, t1.`label` FROM t2 INNER JOIN
1211
(SELECT t1.id_object as id_object FROM t1 WHERE t1.`label` LIKE '%test%') AS lbl
1212
ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
1219
3525 Fournisseur Test
1221
create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=MyISAM;
1222
create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=MyISAM;
1223
create table t3 (a int, b varchar(200), c varchar(200) not null) checksum=1 engine=MEMORY;
1224
create table t4 (a int, b varchar(200), c varchar(200) not null) checksum=0 engine=MEMORY;
1225
create table t5 (a int, b varchar(200), c text not null) checksum=1 engine=MyISAM;
1226
create table t6 (a int, b varchar(200), c text not null) checksum=0 engine=MyISAM;
1227
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
1228
insert t2 select * from t1;
1229
insert t3 select * from t1;
1230
insert t4 select * from t1;
1231
insert t5 select * from t1;
1232
insert t6 select * from t1;
1233
checksum table t1, t2, t3, t4, t5, t6, t7 quick;
1243
Error 1146 Table 'test.t7' doesn't exist
1244
checksum table t1, t2, t3, t4, t5, t6, t7;
1254
Error 1146 Table 'test.t7' doesn't exist
1255
checksum table t1, t2, t3, t4, t5, t6, t7 extended;
1265
Error 1146 Table 'test.t7' doesn't exist
1266
drop table t1,t2,t3, t4, t5, t6;
1267
create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=MyISAM;
1268
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
1269
select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1;
1281
create table t1 (a int) engine=MyISAM;
1282
create table t2 like t1;
1283
show create table t2;
1285
t2 CREATE TABLE `t2` (
1286
`a` int(11) DEFAULT NULL
1287
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1290
show status like "binlog_cache_use";
1293
show status like "binlog_cache_disk_use";
1295
Binlog_cache_disk_use 0
1296
create table t1 (a int) engine=MyISAM;
1297
show status like "binlog_cache_use";
1300
show status like "binlog_cache_disk_use";
1302
Binlog_cache_disk_use 0
1306
show status like "binlog_cache_use";
1309
show status like "binlog_cache_disk_use";
1311
Binlog_cache_disk_use 0
1313
create table t1 (c char(10), index (c,c)) engine=MyISAM;
1314
ERROR 42S21: Duplicate column name 'c'
1315
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=MyISAM;
1316
ERROR 42S21: Duplicate column name 'c1'
1317
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=MyISAM;
1318
ERROR 42S21: Duplicate column name 'c1'
1319
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=MyISAM;
1320
ERROR 42S21: Duplicate column name 'c1'
1321
create table t1 (c1 char(10), c2 char(10)) engine=MyISAM;
1322
alter table t1 add key (c1,c1);
1323
ERROR 42S21: Duplicate column name 'c1'
1324
alter table t1 add key (c2,c1,c1);
1325
ERROR 42S21: Duplicate column name 'c1'
1326
alter table t1 add key (c1,c2,c1);
1327
ERROR 42S21: Duplicate column name 'c1'
1328
alter table t1 add key (c1,c1,c2);
1329
ERROR 42S21: Duplicate column name 'c1'
1331
create table t1(a int(1) , b int(1)) engine=MyISAM;
1332
insert into t1 values ('1111', '3333');
1333
select distinct concat(a, b) from t1;
1337
create temporary table t1 (a int) engine=MyISAM;
1338
insert into t1 values (4711);
1340
insert into t1 values (42);
1345
create table t1 (a int) engine=MyISAM;
1346
insert into t1 values (4711);
1348
insert into t1 values (42);
1353
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;
1354
insert into t1 values (2,2,"b",2,2),(1,1,"a",1,1),(3,3,"ab",3,3);
1355
select * from t1 order by a,b,c,d;
1360
explain select * from t1 order by a,b,c,d;
1361
id select_type table type possible_keys key key_len ref rows Extra
1362
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
1364
create table t1 (a char(1), b char(1), key(a, b)) engine=MyISAM;
1365
insert into t1 values ('8', '6'), ('4', '7');
1366
select min(a) from t1;
1369
select min(b) from t1 where a='8';
1373
create table t1 (x bigint unsigned not null primary key) engine=MyISAM;
1374
insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1);
1377
18446744073709551600
1378
18446744073709551601
1379
select count(*) from t1 where x>0;
1382
select count(*) from t1 where x=0;
1385
select count(*) from t1 where x<0;
1388
select count(*) from t1 where x < -16;
1391
select count(*) from t1 where x = -16;
1394
explain select count(*) from t1 where x > -16;
1395
id select_type table type possible_keys key key_len ref rows Extra
1396
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 2 Using where; Using index
1397
select count(*) from t1 where x > -16;
1400
select * from t1 where x > -16;
1402
18446744073709551600
1403
18446744073709551601
1404
select count(*) from t1 where x = 18446744073709551601;
1408
set storage_engine=MyISAM;
1409
drop table if exists t1,t2,t3;
1410
--- Testing varchar ---
1411
--- Testing varchar ---
1412
create table t1 (v varchar(10), c char(10), t text);
1413
insert into t1 values('+ ', '+ ', '+ ');
1414
set @a=repeat(' ',20);
1415
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1417
Note 1265 Data truncated for column 'v' at row 1
1418
Note 1265 Data truncated for column 'c' at row 1
1419
select concat('*',v,'*',c,'*',t,'*') from t1;
1420
concat('*',v,'*',c,'*',t,'*')
1423
show create table t1;
1425
t1 CREATE TABLE `t1` (
1426
`v` varchar(10) DEFAULT NULL,
1427
`c` char(10) DEFAULT NULL,
1429
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1430
create table t2 like t1;
1431
show create table t2;
1433
t2 CREATE TABLE `t2` (
1434
`v` varchar(10) DEFAULT NULL,
1435
`c` char(10) DEFAULT NULL,
1437
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1438
create table t3 select * from t1;
1439
show create table t3;
1441
t3 CREATE TABLE `t3` (
1442
`v` varchar(10) DEFAULT NULL,
1443
`c` char(10) DEFAULT NULL,
1445
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1446
alter table t1 modify c varchar(10);
1447
show create table t1;
1449
t1 CREATE TABLE `t1` (
1450
`v` varchar(10) DEFAULT NULL,
1451
`c` varchar(10) DEFAULT NULL,
1453
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1454
alter table t1 modify v char(10);
1455
show create table t1;
1457
t1 CREATE TABLE `t1` (
1458
`v` char(10) DEFAULT NULL,
1459
`c` varchar(10) DEFAULT NULL,
1461
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1462
alter table t1 modify t varchar(10);
1464
Note 1265 Data truncated for column 't' at row 2
1465
show create table t1;
1467
t1 CREATE TABLE `t1` (
1468
`v` char(10) DEFAULT NULL,
1469
`c` varchar(10) DEFAULT NULL,
1470
`t` varchar(10) DEFAULT NULL
1471
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1472
select concat('*',v,'*',c,'*',t,'*') from t1;
1473
concat('*',v,'*',c,'*',t,'*')
1476
drop table t1,t2,t3;
1477
create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
1478
show create table t1;
1480
t1 CREATE TABLE `t1` (
1481
`v` varchar(10) DEFAULT NULL,
1482
`c` char(10) DEFAULT NULL,
1487
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1488
select count(*) from t1;
1491
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
1492
select count(*) from t1 where v='a';
1495
select count(*) from t1 where c='a';
1498
select count(*) from t1 where t='a';
1501
select count(*) from t1 where v='a ';
1504
select count(*) from t1 where c='a ';
1507
select count(*) from t1 where t='a ';
1510
select count(*) from t1 where v between 'a' and 'a ';
1513
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1516
select count(*) from t1 where v like 'a%';
1519
select count(*) from t1 where c like 'a%';
1522
select count(*) from t1 where t like 'a%';
1525
select count(*) from t1 where v like 'a %';
1528
explain select count(*) from t1 where v='a ';
1529
id select_type table type possible_keys key key_len ref rows Extra
1530
1 SIMPLE t1 ref v v 13 const # Using where; Using index
1531
explain select count(*) from t1 where c='a ';
1532
id select_type table type possible_keys key key_len ref rows Extra
1533
1 SIMPLE t1 ref c c 11 const # Using where; Using index
1534
explain select count(*) from t1 where t='a ';
1535
id select_type table type possible_keys key key_len ref rows Extra
1536
1 SIMPLE t1 ref t t 13 const # Using where
1537
explain select count(*) from t1 where v like 'a%';
1538
id select_type table type possible_keys key key_len ref rows Extra
1539
1 SIMPLE t1 range v v 13 NULL # Using where; Using index
1540
explain select count(*) from t1 where v between 'a' and 'a ';
1541
id select_type table type possible_keys key key_len ref rows Extra
1542
1 SIMPLE t1 ref v v 13 const # Using where; Using index
1543
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1544
id select_type table type possible_keys key key_len ref rows Extra
1545
1 SIMPLE t1 ref v v 13 const # Using where; Using index
1546
alter table t1 add unique(v);
1547
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1548
alter table t1 add key(v);
1549
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
1561
explain select * from t1 where v='a';
1562
id select_type table type possible_keys key key_len ref rows Extra
1563
1 SIMPLE t1 ref v,v_2 # 13 const # Using index condition
1564
select v,count(*) from t1 group by v limit 10;
1576
select v,count(t) from t1 group by v limit 10;
1588
select v,count(c) from t1 group by v limit 10;
1600
select sql_big_result v,count(t) from t1 group by v limit 10;
1612
select sql_big_result v,count(c) from t1 group by v limit 10;
1624
select c,count(*) from t1 group by c limit 10;
1636
select c,count(t) from t1 group by c limit 10;
1648
select sql_big_result c,count(t) from t1 group by c limit 10;
1660
select t,count(*) from t1 group by t limit 10;
1672
select t,count(t) from t1 group by t limit 10;
1684
select sql_big_result t,count(t) from t1 group by t limit 10;
1696
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
1697
show create table t1;
1699
t1 CREATE TABLE `t1` (
1700
`v` varchar(300) DEFAULT NULL,
1701
`c` char(10) DEFAULT NULL,
1706
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1707
select count(*) from t1 where v='a';
1710
select count(*) from t1 where v='a ';
1713
select count(*) from t1 where v between 'a' and 'a ';
1716
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1719
select count(*) from t1 where v like 'a%';
1722
select count(*) from t1 where v like 'a %';
1725
explain select count(*) from t1 where v='a ';
1726
id select_type table type possible_keys key key_len ref rows Extra
1727
1 SIMPLE t1 ref v v 303 const # Using where; Using index
1728
explain select count(*) from t1 where v like 'a%';
1729
id select_type table type possible_keys key key_len ref rows Extra
1730
1 SIMPLE t1 range v v 303 NULL # Using where; Using index
1731
explain select count(*) from t1 where v between 'a' and 'a ';
1732
id select_type table type possible_keys key key_len ref rows Extra
1733
1 SIMPLE t1 ref v v 303 const # Using where; Using index
1734
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1735
id select_type table type possible_keys key key_len ref rows Extra
1736
1 SIMPLE t1 ref v v 303 const # Using where; Using index
1737
explain select * from t1 where v='a';
1738
id select_type table type possible_keys key key_len ref rows Extra
1739
1 SIMPLE t1 ref v v 303 const # Using index condition
1740
select v,count(*) from t1 group by v limit 10;
1752
select v,count(t) from t1 group by v limit 10;
1764
select sql_big_result v,count(t) from t1 group by v limit 10;
1776
alter table t1 drop key v, add key v (v(30));
1777
show create table t1;
1779
t1 CREATE TABLE `t1` (
1780
`v` varchar(300) DEFAULT NULL,
1781
`c` char(10) DEFAULT NULL,
1786
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1787
select count(*) from t1 where v='a';
1790
select count(*) from t1 where v='a ';
1793
select count(*) from t1 where v between 'a' and 'a ';
1796
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1799
select count(*) from t1 where v like 'a%';
1802
select count(*) from t1 where v like 'a %';
1805
explain select count(*) from t1 where v='a ';
1806
id select_type table type possible_keys key key_len ref rows Extra
1807
1 SIMPLE t1 ref v v 33 const # Using where
1808
explain select count(*) from t1 where v like 'a%';
1809
id select_type table type possible_keys key key_len ref rows Extra
1810
1 SIMPLE t1 range v v 33 NULL # Using where
1811
explain select count(*) from t1 where v between 'a' and 'a ';
1812
id select_type table type possible_keys key key_len ref rows Extra
1813
1 SIMPLE t1 ref v v 33 const # Using where
1814
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1815
id select_type table type possible_keys key key_len ref rows Extra
1816
1 SIMPLE t1 ref v v 33 const # Using where
1817
explain select * from t1 where v='a';
1818
id select_type table type possible_keys key key_len ref rows Extra
1819
1 SIMPLE t1 ref v v 33 const # Using where
1820
select v,count(*) from t1 group by v limit 10;
1832
select v,count(t) from t1 group by v limit 10;
1844
select sql_big_result v,count(t) from t1 group by v limit 10;
1856
alter table t1 modify v varchar(600), drop key v, add key v (v);
1857
show create table t1;
1859
t1 CREATE TABLE `t1` (
1860
`v` varchar(600) DEFAULT NULL,
1861
`c` char(10) DEFAULT NULL,
1866
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1867
select v,count(*) from t1 group by v limit 10;
1879
select v,count(t) from t1 group by v limit 10;
1891
select sql_big_result v,count(t) from t1 group by v limit 10;
1904
create table t1 (a char(10), unique (a));
1905
insert into t1 values ('a ');
1906
insert into t1 values ('a ');
1907
ERROR 23000: Duplicate entry 'a' for key 'a'
1908
alter table t1 modify a varchar(10);
1909
insert into t1 values ('a '),('a '),('a '),('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
insert into t1 values ('a ');
1914
ERROR 23000: Duplicate entry 'a ' for key 'a'
1915
insert into t1 values ('a ');
1916
ERROR 23000: Duplicate entry 'a ' for key 'a'
1917
update t1 set a='a ' where a like 'a%';
1918
select concat(a,'.') from t1;
1921
update t1 set a='abc ' 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;
1929
update t1 set a='a ' where a like 'a ';
1930
select concat(a,'.') from t1;
1934
create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
1935
show create table t1;
1937
t1 CREATE TABLE `t1` (
1938
`v` varchar(10) DEFAULT NULL,
1939
`c` char(10) DEFAULT NULL,
1944
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1946
create table t1 (v char(10) character set utf8);
1947
show create table t1;
1949
t1 CREATE TABLE `t1` (
1950
`v` char(10) CHARACTER SET utf8 DEFAULT NULL
1951
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1953
create table t1 (v varchar(10), c char(10)) row_format=fixed;
1954
show create table t1;
1956
t1 CREATE TABLE `t1` (
1957
`v` varchar(10) DEFAULT NULL,
1958
`c` char(10) DEFAULT NULL
1959
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
1960
insert into t1 values('a','a'),('a ','a ');
1961
select concat('*',v,'*',c,'*') from t1;
1962
concat('*',v,'*',c,'*')
1966
create table t1 (v varchar(65530), key(v(10)));
1967
insert into t1 values(repeat('a',65530));
1968
select length(v) from t1 where v=repeat('a',65530);
1972
create table t1(a int, b varchar(12), key ba(b, a));
1973
insert into t1 values (1, 'A'), (20, NULL);
1974
explain select * from t1 where a=20 and b is null;
1975
id select_type table type possible_keys key key_len ref rows Extra
1976
1 SIMPLE t1 ref ba ba 20 const,const 1 Using where; Using index
1977
select * from t1 where a=20 and b is null;
1981
create table t1 (v varchar(65530), key(v));
1983
Warning 1071 Specified key was too long; max key length is 1332 bytes
1985
create table t1 (v varchar(65536));
1987
Note 1246 Converting column 'v' from VARCHAR to TEXT
1988
show create table t1;
1990
t1 CREATE TABLE `t1` (
1992
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1994
create table t1 (v varchar(65530) character set utf8);
1996
Note 1246 Converting column 'v' from VARCHAR to TEXT
1997
show create table t1;
1999
t1 CREATE TABLE `t1` (
2000
`v` mediumtext CHARACTER SET utf8
2001
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2003
set storage_engine=MEMORY;
2004
create table t1 (v varchar(16384)) engine=MyISAM;
2006
create table t1 (a char(1), b char(1), key(a, b)) engine=MyISAM;
2007
insert into t1 values ('8', '6'), ('4', '7');
2008
select min(a) from t1;
2011
select min(b) from t1 where a='8';
2015
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=MyISAM;
2016
insert into t1 (b) values (1);
2017
replace into t1 (b) values (2), (1), (3);
2024
insert into t1 (b) values (1);
2025
replace into t1 (b) values (2);
2026
replace into t1 (b) values (1);
2027
replace into t1 (b) values (3);
2034
create table t1 (rowid int not null auto_increment, val int not null,primary
2035
key (rowid), unique(val)) engine=MyISAM;
2036
replace into t1 (val) values ('1'),('2');
2037
replace into t1 (val) values ('1'),('2');
2038
insert into t1 (val) values ('1'),('2');
2039
ERROR 23000: Duplicate entry '1' for key 'val'
2045
CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=MyISAM;
2046
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
2047
SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
2050
SELECT GRADE FROM t1 WHERE GRADE= 151;
2054
create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=MyISAM;
2055
create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=MyISAM;
2056
insert into t2 values ('aa','cc');
2057
insert into t1 values ('aa','bb'),('aa','cc');
2058
delete t1 from t1,t2 where f1=f3 and f4='cc';
2062
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2063
insert into t1(a) values (1),(2),(3);
2066
update t1 set b = 5 where a = 2;
2067
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
2069
insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
2070
(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
2071
(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
2072
(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
2073
(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
2078
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2079
create table t2(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2080
create table t3(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2081
create table t4(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2082
create table t5(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
2083
insert into t1(a) values (1),(2),(3);
2084
insert into t2(a) values (1),(2),(3);
2085
insert into t3(a) values (1),(2),(3);
2086
insert into t4(a) values (1),(2),(3);
2087
insert into t3(a) values (5),(7),(8);
2088
insert into t4(a) values (5),(7),(8);
2089
insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
2090
create trigger t1t before insert on t1 for each row begin
2091
INSERT INTO t2 SET a = NEW.a;
2093
create trigger t2t before insert on t2 for each row begin
2094
DELETE FROM t3 WHERE a = NEW.a;
2096
create trigger t3t before delete on t3 for each row begin
2097
UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
2099
create trigger t4t before update on t4 for each row begin
2100
UPDATE t5 SET b = b + 1 where a = NEW.a;
2104
update t1 set b = b + 5 where a = 1;
2105
update t2 set b = b + 5 where a = 1;
2106
update t3 set b = b + 5 where a = 1;
2107
update t4 set b = b + 5 where a = 1;
2108
insert into t5(a) values(20);
2110
insert into t1(a) values(7);
2111
insert into t2(a) values(8);
2112
delete from t2 where a = 3;
2113
update t4 set b = b + 1 where a = 3;
2119
drop table t1, t2, t3, t4, t5;
2120
create table t1(a date) engine=MyISAM;
2121
create table t2(a date, key(a)) engine=MyISAM;
2122
insert into t1 values('2005-10-01');
2123
insert into t2 values('2005-10-01');
2124
select * from t1, t2
2125
where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
2127
2005-10-01 2005-10-01
2129
create table t1 (id int not null, f_id int not null, f int not null,
2130
primary key(f_id, id)) engine=MyISAM;
2131
create table t2 (id int not null,s_id int not null,s varchar(200),
2132
primary key(id)) engine=MyISAM;
2133
INSERT INTO t1 VALUES (8, 1, 3);
2134
INSERT INTO t1 VALUES (1, 2, 1);
2135
INSERT INTO t2 VALUES (1, 0, '');
2136
INSERT INTO t2 VALUES (8, 1, '');
2138
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
2139
WHERE mm.id IS NULL;
2140
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
2141
where mm.id is null lock in share mode;
2144
create table t1(a int not null, b int, primary key(a)) engine=MyISAM;
2145
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
2148
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2149
update t1 set b = 5 where b = 1;
2151
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
2152
select * from t1 where a = 7 and b = 3 for update;
2158
CREATE TABLE t1 ( a int ) ENGINE=MyISAM;
2160
INSERT INTO t1 VALUES (1);
2162
Table Op Msg_type Msg_text
2163
test.t1 optimize status OK