346
366
select * from t1 where id=999;
347
367
id ggid email passwd
349
create TEMPORARY table t1 (
350
370
user_name varchar(12),
352
372
subscribed char(1),
353
user_id int DEFAULT '0' NOT NULL,
373
user_id int(11) DEFAULT '0' NOT NULL,
356
376
access_date date,
357
378
approved datetime,
358
dummy_primary_key int NOT NULL auto_increment,
379
dummy_primary_key int(11) NOT NULL auto_increment,
359
380
PRIMARY KEY (dummy_primary_key)
361
INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','2000-09-07 23:06:59',1);
362
INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','2000-09-07 23:06:59',2);
363
INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','2000-09-07 23:06:59',3);
364
INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','2000-09-07 23:06:59',4);
365
INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','2000-09-07 23:06:59',5);
366
select user_name, password , subscribed, user_id, quota, weight, access_date, approved, dummy_primary_key from t1 order by user_name;
367
user_name password subscribed user_id quota weight access_date approved dummy_primary_key
368
user_0 somepassword N 0 0 0 2000-09-07 2000-09-07 23:06:59 1
369
user_1 somepassword Y 1 1 1 2000-09-07 2000-09-07 23:06:59 2
370
user_2 somepassword N 2 2 1.4142135623731 2000-09-07 2000-09-07 23:06:59 3
371
user_3 somepassword Y 3 3 1.7320508075689 2000-09-07 2000-09-07 23:06:59 4
372
user_4 somepassword N 4 4 2 2000-09-07 2000-09-07 23:06:59 5
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
374
create TEMPORARY table t1 (
375
id int NOT NULL auto_increment,
376
parent_id int DEFAULT '0' NOT NULL,
377
level int DEFAULT '0' NOT NULL,
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,
379
400
KEY parent_id (parent_id),
380
401
KEY level (level)
616
create TEMPORARY table t1 (a int NOT NULL) engine=MyISAM;
661
CREATE TABLE t1 (a int unsigned NOT NULL) engine=MyISAM;
617
662
INSERT INTO t1 VALUES (1);
618
663
SELECT * FROM t1;
622
create TEMPORARY 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;
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;
623
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);
624
669
explain select * from t1 where a > 0 and a < 50;
625
670
id select_type table type possible_keys key key_len ref rows Extra
626
671
1 SIMPLE t1 system PRIMARY NULL NULL NULL #
628
create TEMPORARY table t1 (a char(20), unique (a(5))) engine=MyISAM;
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;
630
create TEMPORARY table t1 (a char(20), index (a(5))) engine=MyISAM;
717
create table t1 (a char(20), index (a(5))) engine=MyISAM;
631
718
show create table t1;
632
719
Table Create Table
633
t1 CREATE TEMPORARY TABLE `t1` (
634
`a` VARCHAR(20) COLLATE utf8_general_ci DEFAULT NULL,
720
t1 CREATE TABLE `t1` (
721
`a` char(20) DEFAULT NULL,
636
) ENGINE=MyISAM COLLATE = utf8_general_ci
723
) ENGINE=MyISAM DEFAULT CHARSET=latin1
638
725
create temporary table t1 (a int not null auto_increment, primary key(a)) engine=MyISAM;
639
726
insert into t1 values (NULL),(NULL),(NULL);
662
749
insert into t1 values (1,'one','one value',101),
663
750
(2,'two','two value',102),(3,'three','three value',103);
664
752
replace into t1 (value,name,uid) values ('other value','two',102);
665
753
delete from t1 where uid=102;
666
755
replace into t1 (value,name,uid) values ('other value','two',102);
667
757
replace into t1 (value,name,uid) values ('other value','two',102);
668
758
select * from t1;
669
759
id name value uid
670
760
1 one one value 101
761
3 three three value 103
671
762
6 two other value 102
672
3 three three value 103
674
764
create database mysqltest;
675
create TEMPORARY table mysqltest.t1 (a int not null) engine= MyISAM;
765
create table mysqltest.t1 (a int not null) engine= MyISAM;
676
766
insert into mysqltest.t1 values(1);
677
create TEMPORARY table mysqltest.t2 (a int not null) engine= MEMORY;
767
create table mysqltest.t2 (a int not null) engine= MEMORY;
678
768
insert into mysqltest.t2 values(1);
679
create TEMPORARY table mysqltest.t3 (a int not null) engine= MEMORY;
769
create table mysqltest.t3 (a int not null) engine= MEMORY;
680
770
insert into mysqltest.t3 values(1);
682
772
drop database mysqltest;
683
773
show tables from mysqltest;
684
ERROR 42000: Unknown schema 'mysqltest'
774
ERROR 42000: Unknown database 'mysqltest'
685
775
set autocommit=0;
686
create TEMPORARY table t1 (a int not null) engine= MyISAM;
776
create table t1 (a int not null) engine= MyISAM;
687
777
insert into t1 values(1),(2);
688
778
truncate table t1;
739
829
id select_type table type possible_keys key key_len ref rows Extra
740
830
1 SIMPLE t1 ALL NULL NULL NULL NULL #
742
create TEMPORARY table t1 (t int not null default 1, key (t)) engine=MyISAM;
832
create table t1 (t int not null default 1, key (t)) engine=MyISAM;
834
Field Type Null Key Default Extra
744
create TEMPORARY 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;
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;
746
901
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
747
902
SELECT @@tx_isolation,@@global.tx_isolation;
782
create TEMPORARY table t1 (a int not null primary key, b int not null, unique (b)) engine=MyISAM;
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;
783
980
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
784
981
UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000;
785
982
SELECT * from t1;
797
create TEMPORARY table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=MyISAM;
798
create TEMPORARY table t2 (a int not null auto_increment primary key, b int) ENGINE = MEMORY;
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;
799
1093
insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
800
1094
insert into t2 (a) select b from t1;
801
1095
insert into t1 (b) select b from t2;
872
create TEMPORARY table t1 (col1 int)ENGINE=MyISAM;
873
create TEMPORARY table t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
1177
CREATE TABLE t1 (col1 int(1))ENGINE=MyISAM;
1178
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
874
1179
(stamp))ENGINE=MyISAM;
875
1180
insert into t1 values (1),(2),(3);
876
1181
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
877
ERROR HY000: Received an invalid value '20020204310000' for a UNIX timestamp.
1183
Warning 1265 Data truncated for column 'stamp' at row 3
878
1184
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
879
1185
'20020204120000' GROUP BY col1;
885
create TEMPORARY table t1 (a int, b varchar(200), c text not null) engine=MyISAM;
886
create TEMPORARY table t2 (a int, b varchar(200), c text not null) engine=MyISAM;
887
create TEMPORARY table t3 (a int, b varchar(200), c varchar(200) not null) engine=MEMORY;
888
create TEMPORARY table t4 (a int, b varchar(200), c varchar(200) not null) engine=MEMORY;
889
create TEMPORARY table t5 (a int, b varchar(200), c text not null) engine=MyISAM;
890
create TEMPORARY table t6 (a int, b varchar(200), c text not null) engine=MyISAM;
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;
891
1227
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
892
1228
insert t2 select * from t1;
893
1229
insert t3 select * from t1;
894
1230
insert t4 select * from t1;
895
1231
insert t5 select * from t1;
896
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
897
1266
drop table t1,t2,t3, t4, t5, t6;
898
create TEMPORARY table t1 (a int) engine=MyISAM;
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;
899
1282
create table t2 like t1;
900
ERROR HY000: Can't create table 'test.t2' (errno: 138)
901
create table t2 like t1 engine=innodb;
902
1283
show create table t2;
903
1284
Table Create Table
904
1285
t2 CREATE TABLE `t2` (
906
) ENGINE=InnoDB COLLATE = utf8_general_ci
1286
`a` int(11) DEFAULT NULL
1287
) ENGINE=MyISAM DEFAULT CHARSET=latin1
907
1288
drop table t1,t2;
909
1290
show status like "binlog_cache_use";
910
1291
Variable_name Value
911
1293
show status like "binlog_cache_disk_use";
912
1294
Variable_name Value
913
create TEMPORARY table t1 (a int) engine=MyISAM;
1295
Binlog_cache_disk_use 0
1296
create table t1 (a int) engine=MyISAM;
914
1297
show status like "binlog_cache_use";
915
1298
Variable_name Value
916
1300
show status like "binlog_cache_disk_use";
917
1301
Variable_name Value
1302
Binlog_cache_disk_use 0
921
1306
show status like "binlog_cache_use";
922
1307
Variable_name Value
923
1309
show status like "binlog_cache_disk_use";
924
1310
Variable_name Value
1311
Binlog_cache_disk_use 0
926
create TEMPORARY table t1 (c char(10), index (c,c)) engine=MyISAM;
1313
create table t1 (c char(10), index (c,c)) engine=MyISAM;
927
1314
ERROR 42S21: Duplicate column name 'c'
928
create TEMPORARY table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=MyISAM;
929
ERROR 42S21: Duplicate column name 'c1'
930
create TEMPORARY table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=MyISAM;
931
ERROR 42S21: Duplicate column name 'c1'
932
create TEMPORARY table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=MyISAM;
933
ERROR 42S21: Duplicate column name 'c1'
934
create TEMPORARY table t1 (c1 char(10), c2 char(10)) engine=MyISAM;
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;
935
1322
alter table t1 add key (c1,c1);
936
1323
ERROR 42S21: Duplicate column name 'c1'
937
1324
alter table t1 add key (c2,c1,c1);
1006
1394
explain select count(*) from t1 where x > -16;
1007
1395
id select_type table type possible_keys key key_len ref rows Extra
1008
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
1396
1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 2 Using where; Using index
1009
1397
select count(*) from t1 where x > -16;
1012
1400
select * from t1 where x > -16;
1402
18446744073709551600
1403
18446744073709551601
1014
1404
select count(*) from t1 where x = 18446744073709551601;
1018
1408
set storage_engine=MyISAM;
1019
1409
drop table if exists t1,t2,t3;
1020
1410
--- Testing varchar ---
1021
1411
--- Testing varchar ---
1022
create TEMPORARY table t1 (v varchar(10), c char(10), t text);
1412
create table t1 (v varchar(10), c char(10), t text);
1023
1413
insert into t1 values('+ ', '+ ', '+ ');
1024
1414
set @a=repeat(' ',20);
1025
1415
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1026
ERROR 22001: Data too long for column 'v' at row 1
1027
set @a=repeat(' ',10);
1028
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1029
ERROR 22001: Data too long for column 'v' at row 1
1030
set @a=repeat(' ',9);
1031
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
1032
1419
select concat('*',v,'*',c,'*',t,'*') from t1;
1033
1420
concat('*',v,'*',c,'*',t,'*')
1036
1423
show create table t1;
1037
1424
Table Create Table
1038
t1 CREATE TEMPORARY TABLE `t1` (
1039
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1040
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1041
`t` TEXT COLLATE utf8_general_ci
1042
) ENGINE=MyISAM COLLATE = utf8_general_ci
1043
create TEMPORARY table t2 like 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;
1044
1431
show create table t2;
1045
1432
Table Create Table
1046
t2 CREATE TEMPORARY TABLE `t2` (
1047
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1048
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1049
`t` TEXT COLLATE utf8_general_ci
1050
) ENGINE=MyISAM COLLATE = utf8_general_ci
1051
create TEMPORARY table t3 select * from t1;
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;
1052
1439
show create table t3;
1053
1440
Table Create Table
1054
t3 CREATE TEMPORARY TABLE `t3` (
1055
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1056
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1057
`t` TEXT COLLATE utf8_general_ci
1058
) ENGINE=MyISAM COLLATE = utf8_general_ci
1441
t3 CREATE TABLE `t3` (
1442
`v` varchar(10) DEFAULT NULL,
1443
`c` char(10) DEFAULT NULL,
1445
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1059
1446
alter table t1 modify c varchar(10);
1060
1447
show create table t1;
1061
1448
Table Create Table
1062
t1 CREATE TEMPORARY TABLE `t1` (
1063
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1064
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1065
`t` TEXT COLLATE utf8_general_ci
1066
) ENGINE=MyISAM COLLATE = utf8_general_ci
1449
t1 CREATE TABLE `t1` (
1450
`v` varchar(10) DEFAULT NULL,
1451
`c` varchar(10) DEFAULT NULL,
1453
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1067
1454
alter table t1 modify v char(10);
1068
1455
show create table t1;
1069
1456
Table Create Table
1070
t1 CREATE TEMPORARY TABLE `t1` (
1071
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1072
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1073
`t` TEXT COLLATE utf8_general_ci
1074
) ENGINE=MyISAM COLLATE = utf8_general_ci
1457
t1 CREATE TABLE `t1` (
1458
`v` char(10) DEFAULT NULL,
1459
`c` varchar(10) DEFAULT NULL,
1461
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1075
1462
alter table t1 modify t varchar(10);
1464
Note 1265 Data truncated for column 't' at row 2
1076
1465
show create table t1;
1077
1466
Table Create Table
1078
t1 CREATE TEMPORARY TABLE `t1` (
1079
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1080
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1081
`t` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
1082
) ENGINE=MyISAM COLLATE = utf8_general_ci
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
1083
1472
select concat('*',v,'*',c,'*',t,'*') from t1;
1084
1473
concat('*',v,'*',c,'*',t,'*')
1087
1476
drop table t1,t2,t3;
1088
create TEMPORARY table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
1477
create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
1089
1478
show create table t1;
1090
1479
Table Create Table
1091
t1 CREATE TEMPORARY TABLE `t1` (
1092
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1093
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1094
`t` TEXT COLLATE utf8_general_ci,
1480
t1 CREATE TABLE `t1` (
1481
`v` varchar(10) DEFAULT NULL,
1482
`c` char(10) DEFAULT NULL,
1097
1486
KEY `t` (`t`(10))
1098
) ENGINE=MyISAM COLLATE = utf8_general_ci
1487
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1099
1488
select count(*) from t1;
1139
1528
explain select count(*) from t1 where v='a ';
1140
1529
id select_type table type possible_keys key key_len ref rows Extra
1141
1 SIMPLE t1 ref v v 43 const # Using where; Using index
1530
1 SIMPLE t1 ref v v 13 const # Using where; Using index
1142
1531
explain select count(*) from t1 where c='a ';
1143
1532
id select_type table type possible_keys key key_len ref rows Extra
1144
1 SIMPLE t1 ref c c 43 const # Using where; Using index
1533
1 SIMPLE t1 ref c c 11 const # Using where; Using index
1145
1534
explain select count(*) from t1 where t='a ';
1146
1535
id select_type table type possible_keys key key_len ref rows Extra
1147
1 SIMPLE t1 ref t t 43 const # Using where
1536
1 SIMPLE t1 ref t t 13 const # Using where
1148
1537
explain select count(*) from t1 where v like 'a%';
1149
1538
id select_type table type possible_keys key key_len ref rows Extra
1150
1 SIMPLE t1 range v v 43 NULL # Using where; Using index
1539
1 SIMPLE t1 range v v 13 NULL # Using where; Using index
1151
1540
explain select count(*) from t1 where v between 'a' and 'a ';
1152
1541
id select_type table type possible_keys key key_len ref rows Extra
1153
1 SIMPLE t1 ref v v 43 const # Using where; Using index
1542
1 SIMPLE t1 ref v v 13 const # Using where; Using index
1154
1543
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1155
1544
id select_type table type possible_keys key key_len ref rows Extra
1156
1 SIMPLE t1 ref v v 43 const # Using where; Using index
1545
1 SIMPLE t1 ref v v 13 const # Using where; Using index
1157
1546
alter table t1 add unique(v);
1158
1547
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1159
1548
alter table t1 add key(v);
1160
1549
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
1172
1561
explain select * from t1 where v='a';
1173
1562
id select_type table type possible_keys key key_len ref rows Extra
1174
1 SIMPLE t1 ref v,v_2 # 43 const # Using where
1563
1 SIMPLE t1 ref v,v_2 # 13 const # Using index condition
1175
1564
select v,count(*) from t1 group by v limit 10;
1547
create TEMPORARY table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
1934
create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
1548
1935
show create table t1;
1549
1936
Table Create Table
1550
t1 CREATE TEMPORARY TABLE `t1` (
1551
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1552
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1553
`t` TEXT COLLATE utf8_general_ci,
1937
t1 CREATE TABLE `t1` (
1938
`v` varchar(10) DEFAULT NULL,
1939
`c` char(10) DEFAULT NULL,
1554
1941
KEY `v` (`v`(5)),
1555
1942
KEY `c` (`c`(5)),
1556
1943
KEY `t` (`t`(5))
1557
) ENGINE=MyISAM COLLATE = utf8_general_ci
1559
create TEMPORARY table t1 (v char(10));
1560
show create table t1;
1562
t1 CREATE TEMPORARY TABLE `t1` (
1563
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
1564
) ENGINE=MyISAM COLLATE = utf8_general_ci
1566
create TEMPORARY table t1 (v varchar(10), c char(10));
1567
show create table t1;
1569
t1 CREATE TEMPORARY TABLE `t1` (
1570
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1571
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
1572
) ENGINE=MyISAM COLLATE = utf8_general_ci
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
1573
1960
insert into t1 values('a','a'),('a ','a ');
1574
1961
select concat('*',v,'*',c,'*') from t1;
1575
1962
concat('*',v,'*',c,'*')
1579
create TEMPORARY table t1(a int, b varchar(12), key ba(b, a));
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));
1580
1973
insert into t1 values (1, 'A'), (20, NULL);
1581
1974
explain select * from t1 where a=20 and b is null;
1582
1975
id select_type table type possible_keys key key_len ref rows Extra
1583
1 SIMPLE t1 ref ba ba 56 const,const 1 Using where; Using index
1976
1 SIMPLE t1 ref ba ba 20 const,const 1 Using where; Using index
1584
1977
select * from t1 where a=20 and b is null;
1588
create TEMPORARY table t1 (a char(1), b char(1), key(a, b)) engine=MyISAM;
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;
1589
2007
insert into t1 values ('8', '6'), ('4', '7');
1590
2008
select min(a) from t1;
1636
create TEMPORARY table t1(a date) engine=MyISAM;
1637
create TEMPORARY table t2(a date, key(a)) engine=MyISAM;
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;
1638
2122
insert into t1 values('2005-10-01');
1639
2123
insert into t2 values('2005-10-01');
1640
2124
select * from t1, t2
1643
2127
2005-10-01 2005-10-01
1644
2128
drop table t1, t2;
1645
create TEMPORARY table t1 (id int not null, f_id int not null, f int not null,
2129
create table t1 (id int not null, f_id int not null, f int not null,
1646
2130
primary key(f_id, id)) engine=MyISAM;
1647
create TEMPORARY table t2 (id int not null,s_id int not null,s varchar(200),
2131
create table t2 (id int not null,s_id int not null,s varchar(200),
1648
2132
primary key(id)) engine=MyISAM;
1649
2133
INSERT INTO t1 VALUES (8, 1, 3);
1650
2134
INSERT INTO t1 VALUES (1, 2, 1);
1651
2135
INSERT INTO t2 VALUES (1, 0, '');
1652
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;
1654
2140
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
1655
2141
where mm.id is null lock in share mode;
1657
2143
drop table t1,t2;
1658
create TEMPORARY table t1 ( a int ) ENGINE=MyISAM;
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;
1660
2160
INSERT INTO t1 VALUES (1);
1661
ALTER TABLE t1 ENGINE=MyISAM;
2162
Table Op Msg_type Msg_text
2163
test.t1 optimize status OK