pbxt suite is now a main-pbxt overlay
This commit is contained in:
parent
e293bdb2c1
commit
e4bfb6f161
@ -37,6 +37,7 @@ insert into t1 values('def',null);
|
||||
insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
|
||||
--sorted_result
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
|
||||
drop table t1;
|
||||
|
@ -70,6 +70,7 @@ INSERT INTO t1 VALUES(1)|
|
||||
|
||||
--echo
|
||||
--echo ---> Log:
|
||||
--sorted_result
|
||||
SELECT msg FROM log|
|
||||
|
||||
--echo
|
||||
@ -91,6 +92,7 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
|
||||
|
||||
--echo
|
||||
--echo ---> Log:
|
||||
--sorted_result
|
||||
SELECT msg FROM mysqltest2.log|
|
||||
|
||||
--echo
|
||||
|
@ -1,5 +0,0 @@
|
||||
if (!`SELECT count(*) FROM information_schema.engines WHERE
|
||||
(support = 'YES' OR support = 'DEFAULT') AND
|
||||
engine = 'pbxt'`){
|
||||
skip Need PBXT engine;
|
||||
}
|
@ -3,8 +3,8 @@ CREATE TABLE t1 (a int, unique (a), b int not null, unique(b), c int not null, i
|
||||
replace into t1 values (1,1,1),(2,2,2),(3,1,3);
|
||||
select * from t1;
|
||||
a b c
|
||||
3 1 3
|
||||
2 2 2
|
||||
3 1 3
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
|
@ -310,7 +310,7 @@ create table t1 (,b int);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'b int)' at line 1
|
||||
create table t1 (a int, key(a));
|
||||
create table t2 (b int, foreign key(b) references t1(a), key(b));
|
||||
drop table if exists t1,t2;
|
||||
drop table if exists t2,t1;
|
||||
create table t1(id int not null, name char(20));
|
||||
insert into t1 values(10,'mysql'),(20,'monty- the creator');
|
||||
create table t2(id int not null);
|
||||
|
@ -2973,16 +2973,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -1158,16 +1158,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -1005,16 +1005,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -2353,16 +2353,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -1012,16 +1012,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -2353,16 +2353,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -299,16 +299,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -299,16 +299,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -289,16 +289,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -299,16 +299,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -299,16 +299,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -1395,18 +1395,18 @@ INSERT INTO t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM log|
|
||||
msg
|
||||
koi8r
|
||||
koi8r
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -1426,18 +1426,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM mysqltest2.log|
|
||||
msg
|
||||
koi8r
|
||||
koi8r
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -1668,18 +1668,18 @@ INSERT INTO t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM log|
|
||||
msg
|
||||
koi8r
|
||||
koi8r
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -1699,18 +1699,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM mysqltest2.log|
|
||||
msg
|
||||
koi8r
|
||||
koi8r
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -2103,18 +2103,18 @@ INSERT INTO t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM log|
|
||||
msg
|
||||
koi8r
|
||||
koi8r
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -2134,18 +2134,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM mysqltest2.log|
|
||||
msg
|
||||
koi8r
|
||||
koi8r
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
koi8r
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
|
@ -1395,18 +1395,18 @@ INSERT INTO t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM log|
|
||||
msg
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -1426,18 +1426,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM mysqltest2.log|
|
||||
msg
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -1668,18 +1668,18 @@ INSERT INTO t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM log|
|
||||
msg
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -1699,18 +1699,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM mysqltest2.log|
|
||||
msg
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -2103,18 +2103,18 @@ INSERT INTO t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM log|
|
||||
msg
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
@ -2134,18 +2134,18 @@ INSERT INTO mysqltest2.t1 VALUES(1)|
|
||||
---> Log:
|
||||
SELECT msg FROM mysqltest2.log|
|
||||
msg
|
||||
koi8r_general_ci
|
||||
koi8r_general_ci
|
||||
utf8
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_unicode_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
utf8_general_ci
|
||||
koi8r_general_ci
|
||||
utf8_general_ci
|
||||
utf8
|
||||
|
||||
SELECT
|
||||
COLLATION(@a1) AS ca1,
|
||||
|
@ -28,16 +28,16 @@ insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
@ -410,18 +410,18 @@ ID Name Country Population
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1914 Guiyang CHN 1465200
|
||||
1928 Handan CHN 840000
|
||||
1905 Hangzhou CHN 2190500
|
||||
1895 Harbin CHN 4289800
|
||||
1916 Hefei CHN 1369100
|
||||
1950 Hegang CHN 520000
|
||||
1927 Hohhot CHN 916700
|
||||
1937 Huainan CHN 700000
|
||||
1923 Jilin CHN 1040000
|
||||
1904 Jinan CHN 2278100
|
||||
1944 Jinzhou CHN 570000
|
||||
1905 Hangzhou CHN 2190500
|
||||
1914 Guiyang CHN 1465200
|
||||
1916 Hefei CHN 1369100
|
||||
1923 Jilin CHN 1040000
|
||||
1927 Hohhot CHN 916700
|
||||
1928 Handan CHN 840000
|
||||
1937 Huainan CHN 700000
|
||||
1938 Jixi CHN 683885
|
||||
1944 Jinzhou CHN 570000
|
||||
1950 Hegang CHN 520000
|
||||
SELECT COUNT(*) FROM City WHERE ID BETWEEN 501 AND 1000;
|
||||
COUNT(*)
|
||||
500
|
||||
@ -768,15 +768,15 @@ ID Name Country Population
|
||||
SELECT * FROM City WHERE
|
||||
Name LIKE 'M%' AND Population > 1500000;
|
||||
ID Name Country Population
|
||||
131 Melbourne AUS 2865329
|
||||
653 Madrid ESP 2879052
|
||||
766 Manila PHL 1581082
|
||||
942 Medan IDN 1843919
|
||||
1024 Mumbai (Bombay) IND 10500000
|
||||
131 Melbourne AUS 2865329
|
||||
1381 Mashhad IRN 1887405
|
||||
2259 Medellín COL 1861265
|
||||
3520 Minsk BLR 1674000
|
||||
3580 Moscow RUS 8389200
|
||||
653 Madrid ESP 2879052
|
||||
766 Manila PHL 1581082
|
||||
942 Medan IDN 1843919
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'B%';
|
||||
ID Name Country Population
|
||||
@ -785,14 +785,14 @@ ID Name Country Population
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%';
|
||||
ID Name Country Population
|
||||
1914 Guiyang CHN 1465200
|
||||
1928 Handan CHN 840000
|
||||
1905 Hangzhou CHN 2190500
|
||||
1895 Harbin CHN 4289800
|
||||
1905 Hangzhou CHN 2190500
|
||||
1914 Guiyang CHN 1465200
|
||||
1916 Hefei CHN 1369100
|
||||
1950 Hegang CHN 520000
|
||||
1927 Hohhot CHN 916700
|
||||
1928 Handan CHN 840000
|
||||
1937 Huainan CHN 700000
|
||||
1950 Hegang CHN 520000
|
||||
SELECT * FROM City
|
||||
WHERE ID BETWEEN 1 AND 500 AND Population > 1000000 AND Country LIKE 'A%';
|
||||
ID Name Country Population
|
||||
@ -1039,8 +1039,8 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
SELECT * FROM t1
|
||||
WHERE (f1 < 535 OR f1 > 985) AND ( f4='r' OR f4 LIKE 'a%' ) ;
|
||||
f1 f4 f5
|
||||
994 r 2
|
||||
996 A 2
|
||||
998 a 0
|
||||
994 r 2
|
||||
DROP TABLE t1;
|
||||
SET SESSION optimizer_switch='index_merge_sort_intersection=on';
|
||||
|
@ -769,15 +769,15 @@ ID Name Country Population
|
||||
SELECT * FROM City WHERE
|
||||
Name LIKE 'M%' AND Population > 1500000;
|
||||
ID Name Country Population
|
||||
131 Melbourne AUS 2865329
|
||||
653 Madrid ESP 2879052
|
||||
766 Manila PHL 1581082
|
||||
942 Medan IDN 1843919
|
||||
1024 Mumbai (Bombay) IND 10500000
|
||||
131 Melbourne AUS 2865329
|
||||
1381 Mashhad IRN 1887405
|
||||
2259 Medellín COL 1861265
|
||||
3520 Minsk BLR 1674000
|
||||
3580 Moscow RUS 8389200
|
||||
653 Madrid ESP 2879052
|
||||
766 Manila PHL 1581082
|
||||
942 Medan IDN 1843919
|
||||
SELECT * FROM City
|
||||
WHERE Name BETWEEN 'G' AND 'J' AND Population > 700000 AND Country LIKE 'B%';
|
||||
ID Name Country Population
|
||||
|
@ -571,8 +571,8 @@ replace into t1 select * from t2;
|
||||
select * from t1;
|
||||
a b
|
||||
1 t1:1
|
||||
3 t2:3
|
||||
2 t2:2
|
||||
3 t2:3
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
|
||||
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
|
||||
@ -763,9 +763,9 @@ SELECT f1, f1 FROM t2 src WHERE f1 < 2
|
||||
ON DUPLICATE KEY UPDATE f1 = 100 + src.f1;
|
||||
SELECT * FROM t2;
|
||||
f1 f2
|
||||
10 10
|
||||
101 1
|
||||
2 2
|
||||
10 10
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 ( a INT KEY, b INT );
|
||||
INSERT INTO t1 VALUES ( 0, 1 );
|
||||
|
@ -1479,14 +1479,14 @@ SELECT @@GLOBAL.server_id;
|
||||
@@GLOBAL.server_id
|
||||
0
|
||||
SET GLOBAL server_id = @old_server_id;
|
||||
SELECT @@GLOBAL.INIT_FILE, @@GLOBAL.INIT_FILE IS NULL;
|
||||
@@GLOBAL.INIT_FILE @@GLOBAL.INIT_FILE IS NULL
|
||||
NULL 1
|
||||
SELECT @@GLOBAL.INIT_CONNECT, @@GLOBAL.INIT_CONNECT IS NULL;
|
||||
@@GLOBAL.INIT_CONNECT @@GLOBAL.INIT_CONNECT IS NULL
|
||||
1
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES ();
|
||||
SET @bug42778= @@sql_safe_updates;
|
||||
SET @@sql_safe_updates= 0;
|
||||
DELETE FROM t1 ORDER BY (@@GLOBAL.INIT_FILE) ASC LIMIT 10;
|
||||
DELETE FROM t1 ORDER BY (@@GLOBAL.INIT_CONNECT) ASC LIMIT 10;
|
||||
SET @@sql_safe_updates= @bug42778;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -1,10 +0,0 @@
|
||||
# Use default setting for mysqld processes
|
||||
!include include/default_mysqld.cnf
|
||||
|
||||
[mysqld.1]
|
||||
pbxt
|
||||
default-storage-engine=pbxt
|
||||
|
||||
[ENV]
|
||||
MASTER_MYSOCK= @mysqld.1.socket
|
||||
MASTER_MYPORT= @mysqld.1.port
|
@ -1,75 +0,0 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (
|
||||
cont_nr int(11) NOT NULL auto_increment,
|
||||
ver_nr int(11) NOT NULL default '0',
|
||||
aufnr int(11) NOT NULL default '0',
|
||||
username varchar(50) NOT NULL default '',
|
||||
hdl_nr int(11) NOT NULL default '0',
|
||||
eintrag date NOT NULL default '0000-00-00',
|
||||
st_klasse varchar(40) NOT NULL default '',
|
||||
st_wert varchar(40) NOT NULL default '',
|
||||
st_zusatz varchar(40) NOT NULL default '',
|
||||
st_bemerkung varchar(255) NOT NULL default '',
|
||||
kunden_art varchar(40) NOT NULL default '',
|
||||
mcbs_knr int(11) default NULL,
|
||||
mcbs_aufnr int(11) NOT NULL default '0',
|
||||
schufa_status char(1) default '?',
|
||||
bemerkung text,
|
||||
wirknetz text,
|
||||
wf_igz int(11) NOT NULL default '0',
|
||||
tarifcode varchar(80) default NULL,
|
||||
recycle char(1) default NULL,
|
||||
sim varchar(30) default NULL,
|
||||
mcbs_tpl varchar(30) default NULL,
|
||||
emp_nr int(11) NOT NULL default '0',
|
||||
laufzeit int(11) default NULL,
|
||||
hdl_name varchar(30) default NULL,
|
||||
prov_hdl_nr int(11) NOT NULL default '0',
|
||||
auto_wirknetz varchar(50) default NULL,
|
||||
auto_billing varchar(50) default NULL,
|
||||
touch timestamp NOT NULL,
|
||||
kategorie varchar(50) default NULL,
|
||||
kundentyp varchar(20) NOT NULL default '',
|
||||
sammel_rech_msisdn varchar(30) NOT NULL default '',
|
||||
p_nr varchar(9) NOT NULL default '',
|
||||
suffix char(3) NOT NULL default '',
|
||||
PRIMARY KEY (cont_nr),
|
||||
KEY idx_aufnr(aufnr),
|
||||
KEY idx_hdl_nr(hdl_nr),
|
||||
KEY idx_st_klasse(st_klasse),
|
||||
KEY ver_nr(ver_nr),
|
||||
KEY eintrag_idx(eintrag),
|
||||
KEY emp_nr_idx(emp_nr),
|
||||
KEY wf_igz(wf_igz),
|
||||
KEY touch(touch),
|
||||
KEY hdl_tag(eintrag,hdl_nr),
|
||||
KEY prov_hdl_nr(prov_hdl_nr),
|
||||
KEY mcbs_aufnr(mcbs_aufnr),
|
||||
KEY kundentyp(kundentyp),
|
||||
KEY p_nr(p_nr,suffix)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007');
|
||||
INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. möchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
|
||||
SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie;
|
||||
Kundentyp kategorie
|
||||
Privat (Private Nutzung) Mobilfunk
|
||||
Warnings:
|
||||
Warning 1052 Column 'kundentyp' in group statement is ambiguous
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
AUFNR varchar(12) NOT NULL default '',
|
||||
PLNFL varchar(6) NOT NULL default '',
|
||||
VORNR varchar(4) NOT NULL default '',
|
||||
xstatus_vor smallint(5) unsigned NOT NULL default '0'
|
||||
);
|
||||
INSERT INTO t1 VALUES ('40004712','000001','0010',9);
|
||||
INSERT INTO t1 VALUES ('40004712','000001','0020',0);
|
||||
UPDATE t1 SET t1.xstatus_vor = Greatest(t1.xstatus_vor,1) WHERE t1.aufnr =
|
||||
"40004712" AND t1.plnfl = "000001" AND t1.vornr > "0010" ORDER BY t1.vornr
|
||||
ASC LIMIT 1;
|
||||
drop table t1;
|
@ -1,913 +0,0 @@
|
||||
drop table if exists t1,t2;
|
||||
drop database if exists mysqltest;
|
||||
create table t1 (
|
||||
col1 int not null auto_increment primary key,
|
||||
col2 varchar(30) not null,
|
||||
col3 varchar (20) not null,
|
||||
col4 varchar(4) not null,
|
||||
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
|
||||
col6 int not null, to_be_deleted int);
|
||||
insert into t1 values (2,4,3,5,"PENDING",1,7);
|
||||
alter table t1
|
||||
add column col4_5 varchar(20) not null after col4,
|
||||
add column col7 varchar(30) not null after col5,
|
||||
add column col8 datetime not null, drop column to_be_deleted,
|
||||
change column col2 fourth varchar(30) not null after col3,
|
||||
modify column col6 int not null first;
|
||||
select * from t1;
|
||||
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
||||
1 2 3 4 5 PENDING 0000-00-00 00:00:00
|
||||
drop table t1;
|
||||
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
|
||||
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
|
||||
alter table t1 add column new_col int, order by payoutid,bandid;
|
||||
select * from t1;
|
||||
bandID payoutID new_col
|
||||
6 1 NULL
|
||||
3 4 NULL
|
||||
1 6 NULL
|
||||
2 6 NULL
|
||||
4 9 NULL
|
||||
5 10 NULL
|
||||
7 12 NULL
|
||||
8 12 NULL
|
||||
alter table t1 order by bandid,payoutid;
|
||||
select * from t1;
|
||||
bandID payoutID new_col
|
||||
1 6 NULL
|
||||
2 6 NULL
|
||||
3 4 NULL
|
||||
4 9 NULL
|
||||
5 10 NULL
|
||||
6 1 NULL
|
||||
7 12 NULL
|
||||
8 12 NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
GROUP_ID int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
LANG_ID smallint(5) unsigned DEFAULT '0' NOT NULL,
|
||||
NAME varchar(80) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (GROUP_ID,LANG_ID),
|
||||
KEY NAME (NAME));
|
||||
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
|
||||
SHOW FULL COLUMNS FROM t1;
|
||||
Field Type Collation Null Key Default Extra Privileges Comment
|
||||
GROUP_ID int(10) unsigned NULL NO PRI 0 #
|
||||
LANG_ID smallint(5) unsigned NULL NO PRI 0 #
|
||||
NAME char(80) latin1_swedish_ci NO MUL NULL #
|
||||
DROP TABLE t1;
|
||||
create table t1 (n int);
|
||||
insert into t1 values(9),(3),(12),(10);
|
||||
alter table t1 order by n;
|
||||
select * from t1;
|
||||
n
|
||||
3
|
||||
9
|
||||
10
|
||||
12
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
id int(11) unsigned NOT NULL default '0',
|
||||
category_id tinyint(4) unsigned NOT NULL default '0',
|
||||
type_id tinyint(4) unsigned NOT NULL default '0',
|
||||
body text NOT NULL,
|
||||
user_id int(11) unsigned NOT NULL default '0',
|
||||
status enum('new','old') NOT NULL default 'new',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (AnamneseId int(10) unsigned NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam;
|
||||
insert into t1 values (null,"hello");
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1 ADD Column new_col int not null;
|
||||
UNLOCK TABLES;
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
DROP TABLE t1;
|
||||
create table t1 (i int unsigned not null auto_increment primary key);
|
||||
insert into t1 values (null),(null),(null),(null);
|
||||
alter table t1 drop i,add i int unsigned not null auto_increment, drop primary key, add primary key (i);
|
||||
select * from t1;
|
||||
i
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
drop table t1;
|
||||
create table t1 (name char(15));
|
||||
insert into t1 (name) values ("current");
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1 (name char(15));
|
||||
insert into mysqltest.t1 (name) values ("mysqltest");
|
||||
select * from t1;
|
||||
name
|
||||
current
|
||||
select * from mysqltest.t1;
|
||||
name
|
||||
mysqltest
|
||||
alter table t1 rename mysqltest.t1;
|
||||
ERROR 42S01: Table 't1' already exists
|
||||
select * from t1;
|
||||
name
|
||||
current
|
||||
select * from mysqltest.t1;
|
||||
name
|
||||
mysqltest
|
||||
drop table t1;
|
||||
drop database mysqltest;
|
||||
create table t1 (n1 int not null, n2 int, n3 int, n4 float,
|
||||
unique(n1),
|
||||
key (n1, n2, n3, n4),
|
||||
key (n2, n3, n4, n1),
|
||||
key (n3, n4, n1, n2),
|
||||
key (n4, n1, n2, n3) );
|
||||
alter table t1 disable keys;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 n1 1 n1 A 0 NULL NULL BTREE
|
||||
t1 1 n1_2 1 n1 A 0 NULL NULL BTREE
|
||||
t1 1 n1_2 2 n2 A 0 NULL NULL YES BTREE
|
||||
t1 1 n1_2 3 n3 A 0 NULL NULL YES BTREE
|
||||
t1 1 n1_2 4 n4 A 0 NULL NULL YES BTREE
|
||||
t1 1 n2 1 n2 A 0 NULL NULL YES BTREE
|
||||
t1 1 n2 2 n3 A 0 NULL NULL YES BTREE
|
||||
t1 1 n2 3 n4 A 0 NULL NULL YES BTREE
|
||||
t1 1 n2 4 n1 A 0 NULL NULL BTREE
|
||||
t1 1 n3 1 n3 A 0 NULL NULL YES BTREE
|
||||
t1 1 n3 2 n4 A 0 NULL NULL YES BTREE
|
||||
t1 1 n3 3 n1 A 0 NULL NULL BTREE
|
||||
t1 1 n3 4 n2 A 0 NULL NULL YES BTREE
|
||||
t1 1 n4 1 n4 A 0 NULL NULL YES BTREE
|
||||
t1 1 n4 2 n1 A 0 NULL NULL BTREE
|
||||
t1 1 n4 3 n2 A 0 NULL NULL YES BTREE
|
||||
t1 1 n4 4 n3 A 0 NULL NULL YES BTREE
|
||||
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(9,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(8,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(7,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(6,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(5,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(4,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(3,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(2,RAND()*1000,RAND()*1000,RAND());
|
||||
insert into t1 values(1,RAND()*1000,RAND()*1000,RAND());
|
||||
alter table t1 enable keys;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 n1 1 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n1_2 1 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n1_2 2 n2 A 10 NULL NULL YES BTREE
|
||||
t1 1 n1_2 3 n3 A 10 NULL NULL YES BTREE
|
||||
t1 1 n1_2 4 n4 A 10 NULL NULL YES BTREE
|
||||
t1 1 n2 1 n2 A 10 NULL NULL YES BTREE
|
||||
t1 1 n2 2 n3 A 10 NULL NULL YES BTREE
|
||||
t1 1 n2 3 n4 A 10 NULL NULL YES BTREE
|
||||
t1 1 n2 4 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n3 1 n3 A 10 NULL NULL YES BTREE
|
||||
t1 1 n3 2 n4 A 10 NULL NULL YES BTREE
|
||||
t1 1 n3 3 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n3 4 n2 A 10 NULL NULL YES BTREE
|
||||
t1 1 n4 1 n4 A 10 NULL NULL YES BTREE
|
||||
t1 1 n4 2 n1 A 10 NULL NULL BTREE
|
||||
t1 1 n4 3 n2 A 10 NULL NULL YES BTREE
|
||||
t1 1 n4 4 n3 A 10 NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
create table t1 (i int unsigned not null auto_increment primary key);
|
||||
alter table t1 rename t2;
|
||||
alter table t2 rename t1, add c char(10) comment "no comment";
|
||||
show columns from t1;
|
||||
Field Type Null Key Default Extra
|
||||
i int(10) unsigned NO PRI NULL auto_increment
|
||||
c char(10) YES NULL
|
||||
drop table t1;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values(1,100), (2,100), (3, 100);
|
||||
insert into t1 values(1,99), (2,99), (3, 99);
|
||||
insert into t1 values(1,98), (2,98), (3, 98);
|
||||
insert into t1 values(1,97), (2,97), (3, 97);
|
||||
insert into t1 values(1,96), (2,96), (3, 96);
|
||||
insert into t1 values(1,95), (2,95), (3, 95);
|
||||
insert into t1 values(1,94), (2,94), (3, 94);
|
||||
insert into t1 values(1,93), (2,93), (3, 93);
|
||||
insert into t1 values(1,92), (2,92), (3, 92);
|
||||
insert into t1 values(1,91), (2,91), (3, 91);
|
||||
insert into t1 values(1,90), (2,90), (3, 90);
|
||||
insert into t1 values(1,89), (2,89), (3, 89);
|
||||
insert into t1 values(1,88), (2,88), (3, 88);
|
||||
insert into t1 values(1,87), (2,87), (3, 87);
|
||||
insert into t1 values(1,86), (2,86), (3, 86);
|
||||
insert into t1 values(1,85), (2,85), (3, 85);
|
||||
insert into t1 values(1,84), (2,84), (3, 84);
|
||||
insert into t1 values(1,83), (2,83), (3, 83);
|
||||
insert into t1 values(1,82), (2,82), (3, 82);
|
||||
insert into t1 values(1,81), (2,81), (3, 81);
|
||||
insert into t1 values(1,80), (2,80), (3, 80);
|
||||
insert into t1 values(1,79), (2,79), (3, 79);
|
||||
insert into t1 values(1,78), (2,78), (3, 78);
|
||||
insert into t1 values(1,77), (2,77), (3, 77);
|
||||
insert into t1 values(1,76), (2,76), (3, 76);
|
||||
insert into t1 values(1,75), (2,75), (3, 75);
|
||||
insert into t1 values(1,74), (2,74), (3, 74);
|
||||
insert into t1 values(1,73), (2,73), (3, 73);
|
||||
insert into t1 values(1,72), (2,72), (3, 72);
|
||||
insert into t1 values(1,71), (2,71), (3, 71);
|
||||
insert into t1 values(1,70), (2,70), (3, 70);
|
||||
insert into t1 values(1,69), (2,69), (3, 69);
|
||||
insert into t1 values(1,68), (2,68), (3, 68);
|
||||
insert into t1 values(1,67), (2,67), (3, 67);
|
||||
insert into t1 values(1,66), (2,66), (3, 66);
|
||||
insert into t1 values(1,65), (2,65), (3, 65);
|
||||
insert into t1 values(1,64), (2,64), (3, 64);
|
||||
insert into t1 values(1,63), (2,63), (3, 63);
|
||||
insert into t1 values(1,62), (2,62), (3, 62);
|
||||
insert into t1 values(1,61), (2,61), (3, 61);
|
||||
insert into t1 values(1,60), (2,60), (3, 60);
|
||||
insert into t1 values(1,59), (2,59), (3, 59);
|
||||
insert into t1 values(1,58), (2,58), (3, 58);
|
||||
insert into t1 values(1,57), (2,57), (3, 57);
|
||||
insert into t1 values(1,56), (2,56), (3, 56);
|
||||
insert into t1 values(1,55), (2,55), (3, 55);
|
||||
insert into t1 values(1,54), (2,54), (3, 54);
|
||||
insert into t1 values(1,53), (2,53), (3, 53);
|
||||
insert into t1 values(1,52), (2,52), (3, 52);
|
||||
insert into t1 values(1,51), (2,51), (3, 51);
|
||||
insert into t1 values(1,50), (2,50), (3, 50);
|
||||
insert into t1 values(1,49), (2,49), (3, 49);
|
||||
insert into t1 values(1,48), (2,48), (3, 48);
|
||||
insert into t1 values(1,47), (2,47), (3, 47);
|
||||
insert into t1 values(1,46), (2,46), (3, 46);
|
||||
insert into t1 values(1,45), (2,45), (3, 45);
|
||||
insert into t1 values(1,44), (2,44), (3, 44);
|
||||
insert into t1 values(1,43), (2,43), (3, 43);
|
||||
insert into t1 values(1,42), (2,42), (3, 42);
|
||||
insert into t1 values(1,41), (2,41), (3, 41);
|
||||
insert into t1 values(1,40), (2,40), (3, 40);
|
||||
insert into t1 values(1,39), (2,39), (3, 39);
|
||||
insert into t1 values(1,38), (2,38), (3, 38);
|
||||
insert into t1 values(1,37), (2,37), (3, 37);
|
||||
insert into t1 values(1,36), (2,36), (3, 36);
|
||||
insert into t1 values(1,35), (2,35), (3, 35);
|
||||
insert into t1 values(1,34), (2,34), (3, 34);
|
||||
insert into t1 values(1,33), (2,33), (3, 33);
|
||||
insert into t1 values(1,32), (2,32), (3, 32);
|
||||
insert into t1 values(1,31), (2,31), (3, 31);
|
||||
insert into t1 values(1,30), (2,30), (3, 30);
|
||||
insert into t1 values(1,29), (2,29), (3, 29);
|
||||
insert into t1 values(1,28), (2,28), (3, 28);
|
||||
insert into t1 values(1,27), (2,27), (3, 27);
|
||||
insert into t1 values(1,26), (2,26), (3, 26);
|
||||
insert into t1 values(1,25), (2,25), (3, 25);
|
||||
insert into t1 values(1,24), (2,24), (3, 24);
|
||||
insert into t1 values(1,23), (2,23), (3, 23);
|
||||
insert into t1 values(1,22), (2,22), (3, 22);
|
||||
insert into t1 values(1,21), (2,21), (3, 21);
|
||||
insert into t1 values(1,20), (2,20), (3, 20);
|
||||
insert into t1 values(1,19), (2,19), (3, 19);
|
||||
insert into t1 values(1,18), (2,18), (3, 18);
|
||||
insert into t1 values(1,17), (2,17), (3, 17);
|
||||
insert into t1 values(1,16), (2,16), (3, 16);
|
||||
insert into t1 values(1,15), (2,15), (3, 15);
|
||||
insert into t1 values(1,14), (2,14), (3, 14);
|
||||
insert into t1 values(1,13), (2,13), (3, 13);
|
||||
insert into t1 values(1,12), (2,12), (3, 12);
|
||||
insert into t1 values(1,11), (2,11), (3, 11);
|
||||
insert into t1 values(1,10), (2,10), (3, 10);
|
||||
insert into t1 values(1,9), (2,9), (3, 9);
|
||||
insert into t1 values(1,8), (2,8), (3, 8);
|
||||
insert into t1 values(1,7), (2,7), (3, 7);
|
||||
insert into t1 values(1,6), (2,6), (3, 6);
|
||||
insert into t1 values(1,5), (2,5), (3, 5);
|
||||
insert into t1 values(1,4), (2,4), (3, 4);
|
||||
insert into t1 values(1,3), (2,3), (3, 3);
|
||||
insert into t1 values(1,2), (2,2), (3, 2);
|
||||
insert into t1 values(1,1), (2,1), (3, 1);
|
||||
alter table t1 add unique (a,b), add key (b);
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 300 NULL NULL YES BTREE
|
||||
t1 0 a 2 b A 300 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 300 NULL NULL YES BTREE
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 300 NULL NULL YES BTREE
|
||||
t1 0 a 2 b A 300 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 300 NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (i int(10), index(i) );
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
INSERT INTO t1 VALUES(1),(2),(3);
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
Host varchar(16) binary NOT NULL default '',
|
||||
User varchar(16) binary NOT NULL default '',
|
||||
PRIMARY KEY (Host,User)
|
||||
) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
LOCK TABLES t1 WRITE;
|
||||
INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
UNLOCK TABLES;
|
||||
CHECK TABLES t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
Host varchar(16) binary NOT NULL default '',
|
||||
User varchar(16) binary NOT NULL default '',
|
||||
PRIMARY KEY (Host,User),
|
||||
KEY (Host)
|
||||
) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
|
||||
LOCK TABLES t1 WRITE;
|
||||
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A 1 NULL NULL BTREE
|
||||
UNLOCK TABLES;
|
||||
CHECK TABLES t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1 RENAME t2;
|
||||
UNLOCK TABLES;
|
||||
select * from t2;
|
||||
Host User
|
||||
localhost
|
||||
localhost root
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t1 (
|
||||
Host varchar(16) binary NOT NULL default '',
|
||||
User varchar(16) binary NOT NULL default '',
|
||||
PRIMARY KEY (Host,User),
|
||||
KEY (Host)
|
||||
) ENGINE=MyISAM;
|
||||
LOCK TABLES t1 WRITE;
|
||||
ALTER TABLE t1 DISABLE KEYS;
|
||||
SHOW INDEX FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
|
||||
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
|
||||
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int);
|
||||
alter table t1 rename to ``;
|
||||
ERROR 42000: Incorrect table name ''
|
||||
rename table t1 to ``;
|
||||
ERROR 42000: Incorrect table name ''
|
||||
drop table t1;
|
||||
drop table if exists t1, t2;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
Note 1051 Unknown table 't2'
|
||||
create table t1 ( a varchar(10) not null primary key ) engine=myisam;
|
||||
create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1);
|
||||
flush tables;
|
||||
alter table t1 modify a varchar(10);
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` varchar(10) NOT NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
|
||||
flush tables;
|
||||
alter table t1 modify a varchar(10) not null;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` varchar(10) NOT NULL,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
|
||||
drop table if exists t1, t2;
|
||||
create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
|
||||
insert into t1 (a) values(1);
|
||||
show table status like 't1';
|
||||
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
||||
t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
|
||||
alter table t1 modify a int;
|
||||
show table status like 't1';
|
||||
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
||||
t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
|
||||
insert into t1 (a) values(1);
|
||||
Warnings:
|
||||
Warning 1364 Field 'b' doesn't have a default value
|
||||
Warning 1364 Field 'c' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'e' doesn't have a default value
|
||||
Warning 1364 Field 'f' doesn't have a default value
|
||||
Warning 1364 Field 'g' doesn't have a default value
|
||||
Warning 1364 Field 'h' doesn't have a default value
|
||||
Warning 1364 Field 'i' doesn't have a default value
|
||||
show table status like 't1';
|
||||
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
||||
t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
|
||||
drop table t1;
|
||||
set names koi8r;
|
||||
create table t1 (a char(10) character set koi8r);
|
||||
insert into t1 values ('ÔÅÓÔ');
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
ÔÅÓÔ D4C5D3D4
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
ÔÅÓÔ F2E5F1F2
|
||||
alter table t1 change a a binary(4);
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
òåñò F2E5F1F2
|
||||
alter table t1 change a a char(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
ÔÅÓÔ F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
ÔÅÓÔ D4C5D3D4
|
||||
alter table t1 change a a varchar(10) character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
ÔÅÓÔ F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
ÔÅÓÔ D4C5D3D4
|
||||
alter table t1 change a a text character set cp1251;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
ÔÅÓÔ F2E5F1F2
|
||||
alter table t1 change a a char(10) character set koi8r;
|
||||
select a,hex(a) from t1;
|
||||
a hex(a)
|
||||
ÔÅÓÔ D4C5D3D4
|
||||
delete from t1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) CHARACTER SET koi8r DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
alter table t1 DEFAULT CHARACTER SET latin1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) CHARACTER SET koi8r DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
alter table t1 CONVERT TO CHARACTER SET latin1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
alter table t1 DEFAULT CHARACTER SET cp1251;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` char(10) CHARACTER SET latin1 DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=cp1251
|
||||
drop table t1;
|
||||
create table t1 (myblob longblob,mytext longtext)
|
||||
default charset latin1 collate latin1_general_cs;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`myblob` longblob,
|
||||
`mytext` longtext COLLATE latin1_general_cs
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
|
||||
alter table t1 character set latin2;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`myblob` longblob,
|
||||
`mytext` longtext CHARACTER SET latin1 COLLATE latin1_general_cs
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin2
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
|
||||
ALTER TABLE t1 DROP PRIMARY KEY;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
UNIQUE KEY `b` (`b`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
ALTER TABLE t1 DROP PRIMARY KEY;
|
||||
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int, b int, key(a));
|
||||
insert into t1 values (1,1), (2,2);
|
||||
alter table t1 drop key no_such_key;
|
||||
ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists
|
||||
alter table t1 drop key a;
|
||||
drop table t1;
|
||||
CREATE TABLE T12207(a int) ENGINE=MYISAM;
|
||||
ALTER TABLE T12207 DISCARD TABLESPACE;
|
||||
ERROR HY000: Table storage engine for 'T12207' doesn't have this option
|
||||
DROP TABLE T12207;
|
||||
create table t1 (a text) character set koi8r;
|
||||
insert into t1 values (_koi8r'ÔÅÓÔ');
|
||||
select hex(a) from t1;
|
||||
hex(a)
|
||||
D4C5D3D4
|
||||
alter table t1 convert to character set cp1251;
|
||||
select hex(a) from t1;
|
||||
hex(a)
|
||||
F2E5F1F2
|
||||
drop table t1;
|
||||
create table t1 ( a timestamp );
|
||||
alter table t1 add unique ( a(1) );
|
||||
ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
|
||||
drop table t1;
|
||||
drop table if exists t1;
|
||||
create table t1 (a int, key(a));
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
"this used not to disable the index"
|
||||
alter table t1 modify a int, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 modify a bigint, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 add b char(10), disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 add c decimal(10,2), enable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
"this however did"
|
||||
alter table t1 disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
a bigint(20) YES MUL NULL
|
||||
b char(10) YES NULL
|
||||
c decimal(10,2) YES NULL
|
||||
alter table t1 add d decimal(15,5);
|
||||
"The key should still be disabled"
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
"Now will test with one unique index"
|
||||
create table t1(a int, b char(10), unique(a));
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
"If no copy on noop change, this won't touch the data file"
|
||||
"Unique index, no change"
|
||||
alter table t1 modify a int, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
"Change the type implying data copy"
|
||||
"Unique index, no change"
|
||||
alter table t1 modify a bigint, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 modify a bigint;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
alter table t1 modify a int;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
"Now will test with one unique and one non-unique index"
|
||||
create table t1(a int, b char(10), unique(a), key(b));
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 0 NULL NULL YES BTREE
|
||||
alter table t1 disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 0 NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
"If no copy on noop change, this won't touch the data file"
|
||||
"The non-unique index will be disabled"
|
||||
alter table t1 modify a int, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 0 NULL NULL YES BTREE
|
||||
alter table t1 enable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 0 NULL NULL YES BTREE
|
||||
"Change the type implying data copy"
|
||||
"The non-unique index will be disabled"
|
||||
alter table t1 modify a bigint, disable keys;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 0 NULL NULL YES BTREE
|
||||
"Change again the type, but leave the indexes as_is"
|
||||
alter table t1 modify a int;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 0 NULL NULL YES BTREE
|
||||
"Try the same. When data is no copied on similar tables, this is noop"
|
||||
alter table t1 modify a int;
|
||||
show indexes from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 a 1 a A 0 NULL NULL YES BTREE
|
||||
t1 1 b 1 b A 0 NULL NULL YES BTREE
|
||||
drop table t1;
|
||||
create database mysqltest;
|
||||
create table t1 (c1 int);
|
||||
alter table t1 rename mysqltest.t1;
|
||||
drop table t1;
|
||||
ERROR 42S02: Unknown table 't1'
|
||||
alter table mysqltest.t1 rename t1;
|
||||
drop table t1;
|
||||
create table t1 (c1 int);
|
||||
use mysqltest;
|
||||
drop database mysqltest;
|
||||
alter table test.t1 rename t1;
|
||||
ERROR 3D000: No database selected
|
||||
alter table test.t1 rename test.t1;
|
||||
use test;
|
||||
drop table t1;
|
||||
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
|
||||
CREATE INDEX i1 ON t1(a);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
KEY `i1` (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
|
||||
DROP INDEX i1 ON t1;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
|
||||
DROP TABLE t1;
|
||||
DROP TABLE IF EXISTS bug24219;
|
||||
DROP TABLE IF EXISTS bug24219_2;
|
||||
CREATE TABLE bug24219 (a INT, INDEX(a));
|
||||
SHOW INDEX FROM bug24219;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
bug24219 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
|
||||
SHOW INDEX FROM bug24219_2;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
bug24219_2 1 a 1 a A 0 NULL NULL YES BTREE
|
||||
DROP TABLE bug24219_2;
|
||||
create table t1 (mycol int(10) not null);
|
||||
alter table t1 alter column mycol set default 0;
|
||||
desc t1;
|
||||
Field Type Null Key Default Extra
|
||||
mycol int(10) NO 0
|
||||
drop table t1;
|
||||
create table t1 (v varchar(32));
|
||||
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
|
||||
select * from t1;
|
||||
v
|
||||
def
|
||||
abc
|
||||
hij
|
||||
3r4f
|
||||
alter table t1 change v v2 varchar(32);
|
||||
select * from t1;
|
||||
v2
|
||||
def
|
||||
abc
|
||||
hij
|
||||
3r4f
|
||||
alter table t1 change v2 v varchar(64);
|
||||
select * from t1;
|
||||
v
|
||||
def
|
||||
abc
|
||||
hij
|
||||
3r4f
|
||||
update t1 set v = 'lmn' where v = 'hij';
|
||||
select * from t1;
|
||||
v
|
||||
def
|
||||
abc
|
||||
3r4f
|
||||
lmn
|
||||
alter table t1 add i int auto_increment not null primary key first;
|
||||
select * from t1;
|
||||
i v
|
||||
1 def
|
||||
2 abc
|
||||
3 3r4f
|
||||
4 lmn
|
||||
update t1 set i=5 where i=3;
|
||||
select * from t1;
|
||||
i v
|
||||
1 def
|
||||
2 abc
|
||||
4 lmn
|
||||
5 3r4f
|
||||
alter table t1 change i i bigint;
|
||||
select * from t1;
|
||||
i v
|
||||
1 def
|
||||
2 abc
|
||||
4 lmn
|
||||
5 3r4f
|
||||
alter table t1 add unique key (i, v);
|
||||
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
|
||||
i v
|
||||
4 lmn
|
||||
drop table t1;
|
||||
create table t1 (t varchar(255) default null, key t (t(80)))
|
||||
engine=myisam default charset=latin1;
|
||||
alter table t1 change t t text;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (s CHAR(8) BINARY);
|
||||
INSERT INTO t1 VALUES ('test');
|
||||
SELECT LENGTH(s) FROM t1;
|
||||
LENGTH(s)
|
||||
4
|
||||
ALTER TABLE t1 MODIFY s CHAR(10) BINARY;
|
||||
SELECT LENGTH(s) FROM t1;
|
||||
LENGTH(s)
|
||||
4
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (s BINARY(8));
|
||||
INSERT INTO t1 VALUES ('test');
|
||||
SELECT LENGTH(s) FROM t1;
|
||||
LENGTH(s)
|
||||
8
|
||||
SELECT HEX(s) FROM t1;
|
||||
HEX(s)
|
||||
7465737400000000
|
||||
ALTER TABLE t1 MODIFY s BINARY(10);
|
||||
SELECT HEX(s) FROM t1;
|
||||
HEX(s)
|
||||
74657374000000000000
|
||||
SELECT LENGTH(s) FROM t1;
|
||||
LENGTH(s)
|
||||
10
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (v VARCHAR(3), b INT);
|
||||
INSERT INTO t1 VALUES ('abc', 5);
|
||||
SELECT * FROM t1;
|
||||
v b
|
||||
abc 5
|
||||
ALTER TABLE t1 MODIFY COLUMN v VARCHAR(4);
|
||||
SELECT * FROM t1;
|
||||
v b
|
||||
abc 5
|
||||
DROP TABLE t1;
|
||||
DROP TABLE IF EXISTS `t+1`, `t+2`;
|
||||
CREATE TABLE `t+1` (c1 INT);
|
||||
ALTER TABLE `t+1` RENAME `t+2`;
|
||||
CREATE TABLE `t+1` (c1 INT);
|
||||
ALTER TABLE `t+1` RENAME `t+2`;
|
||||
ERROR 42S01: Table 't+2' already exists
|
||||
DROP TABLE `t+1`, `t+2`;
|
||||
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
|
||||
ALTER TABLE `tt+1` RENAME `tt+2`;
|
||||
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
|
||||
ALTER TABLE `tt+1` RENAME `tt+2`;
|
||||
ERROR 42S01: Table 'tt+2' already exists
|
||||
SHOW CREATE TABLE `tt+1`;
|
||||
Table Create Table
|
||||
tt+1 CREATE TEMPORARY TABLE `tt+1` (
|
||||
`c1` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
SHOW CREATE TABLE `tt+2`;
|
||||
Table Create Table
|
||||
tt+2 CREATE TEMPORARY TABLE `tt+2` (
|
||||
`c1` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE `tt+1`, `tt+2`;
|
||||
CREATE TABLE `#sql1` (c1 INT);
|
||||
CREATE TABLE `@0023sql2` (c1 INT);
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
#sql1
|
||||
@0023sql2
|
||||
RENAME TABLE `#sql1` TO `@0023sql1`;
|
||||
RENAME TABLE `@0023sql2` TO `#sql2`;
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
#sql2
|
||||
@0023sql1
|
||||
ALTER TABLE `@0023sql1` RENAME `#sql-1`;
|
||||
ALTER TABLE `#sql2` RENAME `@0023sql-2`;
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
#sql-1
|
||||
@0023sql-2
|
||||
INSERT INTO `#sql-1` VALUES (1);
|
||||
INSERT INTO `@0023sql-2` VALUES (2);
|
||||
DROP TABLE `#sql-1`, `@0023sql-2`;
|
||||
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
|
||||
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
ALTER TABLE `#sql1` RENAME `@0023sql1`;
|
||||
ALTER TABLE `@0023sql2` RENAME `#sql2`;
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
INSERT INTO `#sql2` VALUES (1);
|
||||
INSERT INTO `@0023sql1` VALUES (2);
|
||||
SHOW CREATE TABLE `#sql2`;
|
||||
Table Create Table
|
||||
#sql2 CREATE TEMPORARY TABLE `#sql2` (
|
||||
`c1` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
SHOW CREATE TABLE `@0023sql1`;
|
||||
Table Create Table
|
||||
@0023sql1 CREATE TEMPORARY TABLE `@0023sql1` (
|
||||
`c1` int(11) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE `#sql2`, `@0023sql1`;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t1 (
|
||||
int_field INTEGER UNSIGNED NOT NULL,
|
||||
char_field CHAR(10),
|
||||
INDEX(`int_field`)
|
||||
);
|
||||
DESCRIBE t1;
|
||||
Field Type Null Key Default Extra
|
||||
int_field int(10) unsigned NO MUL NULL
|
||||
char_field char(10) YES NULL
|
||||
SHOW INDEXES FROM t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 int_field 1 int_field A 0 NULL NULL BTREE
|
||||
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
|
||||
"Non-copy data change - new frm, but old data and index files"
|
||||
ALTER TABLE t1
|
||||
CHANGE int_field unsigned_int_field INTEGER UNSIGNED NOT NULL,
|
||||
RENAME t2;
|
||||
SELECT * FROM t1 ORDER BY int_field;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
SELECT * FROM t2 ORDER BY unsigned_int_field;
|
||||
unsigned_int_field char_field
|
||||
1 edno
|
||||
1 edno
|
||||
2 dve
|
||||
3 tri
|
||||
5 pet
|
||||
DESCRIBE t2;
|
||||
Field Type Null Key Default Extra
|
||||
unsigned_int_field int(10) unsigned NO MUL NULL
|
||||
char_field char(10) YES NULL
|
||||
DESCRIBE t2;
|
||||
Field Type Null Key Default Extra
|
||||
unsigned_int_field int(10) unsigned NO MUL NULL
|
||||
char_field char(10) YES NULL
|
||||
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT UNSIGNED NOT NULL;
|
||||
DESCRIBE t2;
|
||||
Field Type Null Key Default Extra
|
||||
unsigned_int_field bigint(20) unsigned NO MUL NULL
|
||||
char_field char(10) YES NULL
|
||||
DROP TABLE t2;
|
@ -1,60 +0,0 @@
|
||||
create table t1 (a bigint);
|
||||
lock tables t1 write;
|
||||
insert into t1 values(0);
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
unlock tables;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values(0);
|
||||
lock tables t1 write;
|
||||
delete from t1;
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
unlock tables;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values(0);
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a mediumtext, fulltext key key1(a)) charset utf8 collate utf8_general_ci engine myisam;
|
||||
insert into t1 values ('hello');
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Table is already up to date
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int);
|
||||
prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()";
|
||||
execute stmt1;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.a NULL NULL 0 0 0 0 0.0 0.0 CHAR(0) NOT NULL
|
||||
execute stmt1;
|
||||
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
||||
test.t1.a NULL NULL 0 0 0 0 0.0 0.0 CHAR(0) NOT NULL
|
||||
deallocate prepare stmt1;
|
||||
drop table t1;
|
||||
create temporary table t1(a int, index(a));
|
||||
insert into t1 values('1'),('2'),('3'),('4'),('5');
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
show index from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 1 a 1 a A 5 NULL NULL YES BTREE
|
||||
drop table t1;
|
@ -1,48 +0,0 @@
|
||||
drop table if exists t1;
|
||||
set sql_mode="MySQL40";
|
||||
select @@sql_mode;
|
||||
@@sql_mode
|
||||
MYSQL40,HIGH_NOT_PRECEDENCE
|
||||
set @@sql_mode="ANSI";
|
||||
select @@sql_mode;
|
||||
@@sql_mode
|
||||
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI
|
||||
SELECT 'A' || 'B';
|
||||
'A' || 'B'
|
||||
AB
|
||||
CREATE TABLE t1 (id INT, id2 int);
|
||||
SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
|
||||
id NULL 1 1.1 a
|
||||
SELECT id FROM t1 GROUP BY id2;
|
||||
id
|
||||
drop table t1;
|
||||
SET @@SQL_MODE="";
|
||||
CREATE TABLE t1 (i int auto_increment NOT NULL, PRIMARY KEY (i));
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`i`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
SET @@SQL_MODE="MYSQL323";
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`i`)
|
||||
) TYPE=PBXT
|
||||
SET @@SQL_MODE="MYSQL40";
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`i`)
|
||||
) TYPE=PBXT
|
||||
SET @@SQL_MODE="NO_FIELD_OPTIONS";
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) NOT NULL,
|
||||
PRIMARY KEY (`i`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
@ -1,454 +0,0 @@
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
SET SQL_WARNINGS=1;
|
||||
create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
|
||||
insert into t1 values (1,1),(NULL,3),(NULL,4);
|
||||
delete from t1 where a=4;
|
||||
insert into t1 values (NULL,5),(NULL,6);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
3 3
|
||||
5 5
|
||||
6 6
|
||||
delete from t1 where a=6;
|
||||
replace t1 values (3,1);
|
||||
ALTER TABLE t1 add c int;
|
||||
replace t1 values (3,3,3);
|
||||
insert into t1 values (NULL,7,7);
|
||||
update t1 set a=8,b=b+1,c=c+1 where a=7;
|
||||
insert into t1 values (NULL,9,9);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 NULL
|
||||
3 3 3
|
||||
5 5 NULL
|
||||
8 8 8
|
||||
9 9 9
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||
sval char(20)
|
||||
);
|
||||
insert into t1 values (NULL, "hello");
|
||||
insert into t1 values (NULL, "hey");
|
||||
select * from t1;
|
||||
skey sval
|
||||
1 hello
|
||||
2 hey
|
||||
select _rowid,t1._rowid,skey,sval from t1;
|
||||
_rowid _rowid skey sval
|
||||
1 1 1 hello
|
||||
2 2 2 hey
|
||||
drop table t1;
|
||||
create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b));
|
||||
insert into t1 values ("a",1),("b",2),("a",2),("c",1);
|
||||
insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("e",NULL);
|
||||
insert into t1 (a) values ("a"),("b"),("c"),("d");
|
||||
insert into t1 (a) values ('k'),('d');
|
||||
insert into t1 (a) values ("a");
|
||||
insert into t1 values ("d",last_insert_id());
|
||||
select * from t1;
|
||||
a b
|
||||
a 1
|
||||
a 2
|
||||
a 3
|
||||
a 7
|
||||
a 13
|
||||
b 2
|
||||
b 4
|
||||
b 8
|
||||
c 1
|
||||
c 5
|
||||
c 9
|
||||
d 10
|
||||
d 12
|
||||
d 13
|
||||
e 6
|
||||
k 11
|
||||
drop table t1;
|
||||
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ordid), index(ord,ordid));
|
||||
insert into t1 (ordid,ord) values (NULL,'sdj'),(NULL,'sdj');
|
||||
select * from t1;
|
||||
ordid ord
|
||||
1 sdj
|
||||
2 sdj
|
||||
drop table t1;
|
||||
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid));
|
||||
insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc');
|
||||
select * from t1;
|
||||
ordid ord
|
||||
3 abc
|
||||
4 abc
|
||||
7 abc
|
||||
1 sdj
|
||||
2 sdj
|
||||
6 sdj
|
||||
5 zzz
|
||||
drop table t1;
|
||||
create table t1 (sid char(5), id int(2) NOT NULL auto_increment, key(sid, id));
|
||||
create table t2 (sid char(20), id int(2));
|
||||
insert into t2 values ('skr',NULL),('skr',NULL),('test',NULL);
|
||||
insert into t1 select * from t2;
|
||||
select * from t1;
|
||||
sid id
|
||||
skr 1
|
||||
skr 2
|
||||
test 3
|
||||
drop table t1,t2;
|
||||
create table t1 (a int not null primary key auto_increment);
|
||||
insert into t1 values (0);
|
||||
update t1 set a=0;
|
||||
select * from t1;
|
||||
a
|
||||
0
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment primary key);
|
||||
insert into t1 values (NULL);
|
||||
insert into t1 values (-1);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
1
|
||||
insert into t1 values (NULL);
|
||||
select * from t1;
|
||||
a
|
||||
-1
|
||||
1
|
||||
2
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment primary key) /*!40102 engine=heap */;
|
||||
insert into t1 values (NULL);
|
||||
insert into t1 values (-1);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
1
|
||||
insert into t1 values (NULL);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
-1
|
||||
2
|
||||
drop table t1;
|
||||
create table t1 (i tinyint unsigned not null auto_increment primary key);
|
||||
insert into t1 set i = 254;
|
||||
insert into t1 set i = null;
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
explain extended select last_insert_id();
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select last_insert_id() AS `last_insert_id()`
|
||||
insert into t1 set i = 254;
|
||||
ERROR 23000: Duplicate entry '254' for key 'PRIMARY'
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
insert into t1 set i = null;
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
drop table t1;
|
||||
create table t1 (i tinyint unsigned not null auto_increment, key (i));
|
||||
insert into t1 set i = 254;
|
||||
insert into t1 set i = null;
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
insert into t1 set i = null;
|
||||
ERROR HY000: Failed to read auto-increment value from storage engine
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
255
|
||||
drop table t1;
|
||||
create table t1 (i tinyint unsigned not null auto_increment primary key, b int, unique (b));
|
||||
insert into t1 values (NULL, 10);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
1
|
||||
insert into t1 values (NULL, 15);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
2
|
||||
insert into t1 values (NULL, 10);
|
||||
ERROR 23000: Duplicate entry '10' for key 'b'
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
2
|
||||
drop table t1;
|
||||
create table t1(a int auto_increment,b int null,primary key(a));
|
||||
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
|
||||
insert into t1(a,b)values(NULL,1);
|
||||
insert into t1(a,b)values(200,2);
|
||||
insert into t1(a,b)values(0,3);
|
||||
insert into t1(b)values(4);
|
||||
insert into t1(b)values(5);
|
||||
insert into t1(b)values(6);
|
||||
insert into t1(b)values(7);
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
0 3
|
||||
201 4
|
||||
202 5
|
||||
203 6
|
||||
204 7
|
||||
alter table t1 modify b mediumint;
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
0 3
|
||||
201 4
|
||||
202 5
|
||||
203 6
|
||||
204 7
|
||||
create table t2 (a int);
|
||||
insert t2 values (1),(2);
|
||||
alter table t2 add b int auto_increment primary key;
|
||||
select * from t2;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
drop table t2;
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=0 where b=5;
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
201 4
|
||||
0 5
|
||||
203 6
|
||||
204 7
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=NULL where b=6;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
update t1 set a=300 where b=7;
|
||||
SET SQL_MODE='';
|
||||
insert into t1(a,b)values(NULL,8);
|
||||
insert into t1(a,b)values(400,9);
|
||||
insert into t1(a,b)values(0,10);
|
||||
insert into t1(b)values(11);
|
||||
insert into t1(b)values(12);
|
||||
insert into t1(b)values(13);
|
||||
insert into t1(b)values(14);
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
201 4
|
||||
0 6
|
||||
300 7
|
||||
301 8
|
||||
400 9
|
||||
401 10
|
||||
402 11
|
||||
403 12
|
||||
404 13
|
||||
405 14
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=0 where b=12;
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
201 4
|
||||
300 7
|
||||
301 8
|
||||
400 9
|
||||
401 10
|
||||
402 11
|
||||
0 12
|
||||
404 13
|
||||
405 14
|
||||
delete from t1 where a=0;
|
||||
update t1 set a=NULL where b=13;
|
||||
Warnings:
|
||||
Warning 1048 Column 'a' cannot be null
|
||||
update t1 set a=500 where b=14;
|
||||
select * from t1 order by b;
|
||||
a b
|
||||
1 1
|
||||
200 2
|
||||
201 4
|
||||
300 7
|
||||
301 8
|
||||
400 9
|
||||
401 10
|
||||
402 11
|
||||
0 13
|
||||
500 14
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values (1), (2), (3), (NULL), (NULL);
|
||||
alter table t1 modify a bigint not null auto_increment primary key;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values (1), (2), (3), (0), (0);
|
||||
alter table t1 modify a bigint not null auto_increment primary key;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values (0), (1), (2), (3);
|
||||
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
|
||||
alter table t1 modify a bigint not null auto_increment primary key;
|
||||
set sql_mode= '';
|
||||
select * from t1;
|
||||
a
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
drop table t1;
|
||||
create table t1 (a int auto_increment primary key , b int null);
|
||||
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
|
||||
insert into t1 values (0,1),(1,2),(2,3);
|
||||
select * from t1;
|
||||
a b
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
set sql_mode= '';
|
||||
alter table t1 modify b varchar(255);
|
||||
insert into t1 values (0,4);
|
||||
select * from t1;
|
||||
a b
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
|
||||
INSERT INTO t1 (b) VALUES ('aaaa');
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
INSERT INTO t1 (b) VALUES ('');
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
INSERT INTO t1 (b) VALUES ('bbbb');
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE `t1` (
|
||||
t1_name VARCHAR(255) DEFAULT NULL,
|
||||
t1_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
KEY (t1_name),
|
||||
PRIMARY KEY (t1_id)
|
||||
) AUTO_INCREMENT = 1000;
|
||||
INSERT INTO t1 (t1_name) VALUES('MySQL');
|
||||
INSERT INTO t1 (t1_name) VALUES('MySQL');
|
||||
INSERT INTO t1 (t1_name) VALUES('MySQL');
|
||||
SELECT * from t1;
|
||||
t1_name t1_id
|
||||
MySQL 1000
|
||||
MySQL 1001
|
||||
MySQL 1002
|
||||
SHOW CREATE TABLE `t1`;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`t1_name` varchar(255) DEFAULT NULL,
|
||||
`t1_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`t1_id`),
|
||||
KEY `t1_name` (`t1_name`)
|
||||
) ENGINE=PBXT AUTO_INCREMENT=1000 DEFAULT CHARSET=latin1
|
||||
DROP TABLE `t1`;
|
||||
create table t1(a int not null auto_increment primary key);
|
||||
create table t2(a int not null auto_increment primary key, t1a int);
|
||||
insert into t1 values(NULL);
|
||||
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
|
||||
insert into t1 values (NULL);
|
||||
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
|
||||
(NULL, LAST_INSERT_ID());
|
||||
insert into t1 values (NULL);
|
||||
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
|
||||
(NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
|
||||
select * from t2;
|
||||
a t1a
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
4 2
|
||||
5 2
|
||||
6 3
|
||||
7 3
|
||||
8 3
|
||||
9 3
|
||||
drop table t1, t2;
|
||||
End of 4.1 tests
|
||||
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`));
|
||||
insert into t1 (b) values (1);
|
||||
replace into t1 (b) values (2), (1), (3);
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 1
|
||||
4 3
|
||||
truncate table t1;
|
||||
insert into t1 (b) values (1);
|
||||
replace into t1 (b) values (2);
|
||||
replace into t1 (b) values (1);
|
||||
replace into t1 (b) values (3);
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
2 2
|
||||
3 1
|
||||
4 3
|
||||
drop table t1;
|
||||
create table t1 (rowid int not null auto_increment, val int not null,primary
|
||||
key (rowid), unique(val));
|
||||
replace into t1 (val) values ('1'),('2');
|
||||
replace into t1 (val) values ('1'),('2');
|
||||
insert into t1 (val) values ('1'),('2');
|
||||
ERROR 23000: Duplicate entry '1' for key 'val'
|
||||
select * from t1;
|
||||
rowid val
|
||||
3 1
|
||||
4 2
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment primary key, val int);
|
||||
insert into t1 (val) values (1);
|
||||
update t1 set a=2 where a=1;
|
||||
insert into t1 (val) values (1);
|
||||
select * from t1 order by a;
|
||||
a val
|
||||
2 1
|
||||
3 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
|
||||
INSERT INTO t1 VALUES(0, 0);
|
||||
INSERT INTO t1 VALUES(1, 1);
|
||||
ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
|
||||
ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c));
|
||||
insert into t1 values(null,1,1,now());
|
||||
insert into t1 values(null,0,0,null);
|
||||
replace into t1 values(null,1,0,null);
|
||||
select last_insert_id();
|
||||
last_insert_id()
|
||||
3
|
||||
drop table t1;
|
@ -1,11 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1(n int not null, key(n)) delay_key_write = 1;
|
||||
select count(distinct n) from t1;
|
||||
count(distinct n)
|
||||
100
|
||||
explain extended select count(distinct n) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 range NULL n 4 NULL 201 99.50 Using index for group-by (scanning)
|
||||
Warnings:
|
||||
Note 1003 select count(distinct `test`.`t1`.`n`) AS `count(distinct n)` from `test`.`t1`
|
||||
drop table t1;
|
@ -1,354 +0,0 @@
|
||||
drop table if exists t1, t2;
|
||||
select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
|
||||
0 256 00000000000000065536 2147483647 -2147483648 2147483648 4294967296
|
||||
0 256 65536 2147483647 -2147483648 2147483648 4294967296
|
||||
select 9223372036854775807,-009223372036854775808;
|
||||
9223372036854775807 -009223372036854775808
|
||||
9223372036854775807 -9223372036854775808
|
||||
select +9999999999999999999,-9999999999999999999;
|
||||
9999999999999999999 -9999999999999999999
|
||||
9999999999999999999 -9999999999999999999
|
||||
select cast(9223372036854775808 as unsigned)+1;
|
||||
cast(9223372036854775808 as unsigned)+1
|
||||
9223372036854775809
|
||||
select 9223372036854775808+1;
|
||||
9223372036854775808+1
|
||||
9223372036854775809
|
||||
select -(0-3),round(-(0-3)), round(9999999999999999999);
|
||||
-(0-3) round(-(0-3)) round(9999999999999999999)
|
||||
3 3 9999999999999999999
|
||||
select 1,11,101,1001,10001,100001,1000001,10000001,100000001,1000000001,10000000001,100000000001,1000000000001,10000000000001,100000000000001,1000000000000001,10000000000000001,100000000000000001,1000000000000000001,10000000000000000001;
|
||||
1 11 101 1001 10001 100001 1000001 10000001 100000001 1000000001 10000000001 100000000001 1000000000001 10000000000001 100000000000001 1000000000000001 10000000000000001 100000000000000001 1000000000000000001 10000000000000000001
|
||||
1 11 101 1001 10001 100001 1000001 10000001 100000001 1000000001 10000000001 100000000001 1000000000001 10000000000001 100000000000001 1000000000000001 10000000000000001 100000000000000001 1000000000000000001 10000000000000000001
|
||||
select -1,-11,-101,-1001,-10001,-100001,-1000001,-10000001,-100000001,-1000000001,-10000000001,-100000000001,-1000000000001,-10000000000001,-100000000000001,-1000000000000001,-10000000000000001,-100000000000000001,-1000000000000000001,-10000000000000000001;
|
||||
-1 -11 -101 -1001 -10001 -100001 -1000001 -10000001 -100000001 -1000000001 -10000000001 -100000000001 -1000000000001 -10000000000001 -100000000000001 -1000000000000001 -10000000000000001 -100000000000000001 -1000000000000000001 -10000000000000000001
|
||||
-1 -11 -101 -1001 -10001 -100001 -1000001 -10000001 -100000001 -1000000001 -10000000001 -100000000001 -1000000000001 -10000000000001 -100000000000001 -1000000000000001 -10000000000000001 -100000000000000001 -1000000000000000001 -10000000000000000001
|
||||
select conv(1,10,16),conv((1<<2)-1,10,16),conv((1<<10)-2,10,16),conv((1<<16)-3,10,16),conv((1<<25)-4,10,16),conv((1<<31)-5,10,16),conv((1<<36)-6,10,16),conv((1<<47)-7,10,16),conv((1<<48)-8,10,16),conv((1<<55)-9,10,16),conv((1<<56)-10,10,16),conv((1<<63)-11,10,16);
|
||||
conv(1,10,16) conv((1<<2)-1,10,16) conv((1<<10)-2,10,16) conv((1<<16)-3,10,16) conv((1<<25)-4,10,16) conv((1<<31)-5,10,16) conv((1<<36)-6,10,16) conv((1<<47)-7,10,16) conv((1<<48)-8,10,16) conv((1<<55)-9,10,16) conv((1<<56)-10,10,16) conv((1<<63)-11,10,16)
|
||||
1 3 3FE FFFD 1FFFFFC 7FFFFFFB FFFFFFFFA 7FFFFFFFFFF9 FFFFFFFFFFF8 7FFFFFFFFFFFF7 FFFFFFFFFFFFF6 7FFFFFFFFFFFFFF5
|
||||
create table t1 (a bigint unsigned not null, primary key(a));
|
||||
insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
|
||||
select * from t1;
|
||||
a
|
||||
18446744073709551612
|
||||
18446744073709551613
|
||||
18446744073709551614
|
||||
18446744073709551615
|
||||
select * from t1 where a=18446744073709551615;
|
||||
a
|
||||
18446744073709551615
|
||||
delete from t1 where a=18446744073709551615;
|
||||
select * from t1;
|
||||
a
|
||||
18446744073709551612
|
||||
18446744073709551613
|
||||
18446744073709551614
|
||||
drop table t1;
|
||||
create table t1 ( a int not null default 1, big bigint );
|
||||
insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(18446744073709551615);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'big' at row 4
|
||||
select * from t1;
|
||||
a big
|
||||
1 -1
|
||||
1 12345678901234567
|
||||
1 9223372036854775807
|
||||
1 9223372036854775807
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
-1 9223372036854775807 9223372036854775806
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
-1 9223372036854775807 9223372036854775806
|
||||
alter table t1 modify big bigint unsigned not null;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'big' at row 1
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
0 9223372036854775807 9223372036854775806
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
0 9223372036854775807 9223372036854775806
|
||||
insert into t1 (big) values (18446744073709551615);
|
||||
select * from t1;
|
||||
a big
|
||||
1 0
|
||||
1 12345678901234567
|
||||
1 9223372036854775807
|
||||
1 9223372036854775807
|
||||
1 18446744073709551615
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
0 18446744073709551615 18446744073709551614
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
0 18446744073709551615 18446744073709551614
|
||||
alter table t1 add key (big);
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
0 18446744073709551615 18446744073709551614
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
0 18446744073709551615 18446744073709551614
|
||||
alter table t1 modify big bigint not null;
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'big' at row 5
|
||||
select * from t1;
|
||||
a big
|
||||
1 0
|
||||
1 12345678901234567
|
||||
1 9223372036854775807
|
||||
1 9223372036854775807
|
||||
1 9223372036854775807
|
||||
select min(big),max(big),max(big)-1 from t1;
|
||||
min(big) max(big) max(big)-1
|
||||
0 9223372036854775807 9223372036854775806
|
||||
select min(big),max(big),max(big)-1 from t1 group by a;
|
||||
min(big) max(big) max(big)-1
|
||||
0 9223372036854775807 9223372036854775806
|
||||
drop table t1;
|
||||
create table t1 (id bigint auto_increment primary key, a int) auto_increment=9999999999;
|
||||
insert into t1 values (null,1);
|
||||
select * from t1;
|
||||
id a
|
||||
9999999999 1
|
||||
select * from t1 limit 9999999999;
|
||||
id a
|
||||
9999999999 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( quantity decimal(60,0));
|
||||
insert into t1 values (10000000000000000000);
|
||||
insert into t1 values (10000000000000000000.0);
|
||||
insert into t1 values ('10000000000000000000');
|
||||
select * from t1;
|
||||
quantity
|
||||
10000000000000000000
|
||||
10000000000000000000
|
||||
10000000000000000000
|
||||
drop table t1;
|
||||
SELECT '0x8000000000000001'+0;
|
||||
'0x8000000000000001'+0
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '0x8000000000000001'
|
||||
create table t1 (
|
||||
value64 bigint unsigned not null,
|
||||
value32 integer not null,
|
||||
primary key(value64, value32)
|
||||
);
|
||||
create table t2 (
|
||||
value64 bigint unsigned not null,
|
||||
value32 integer not null,
|
||||
primary key(value64, value32)
|
||||
);
|
||||
insert into t1 values(17156792991891826145, 1);
|
||||
insert into t1 values( 9223372036854775807, 2);
|
||||
insert into t2 values(17156792991891826145, 3);
|
||||
insert into t2 values( 9223372036854775807, 4);
|
||||
select * from t1;
|
||||
value64 value32
|
||||
9223372036854775807 2
|
||||
17156792991891826145 1
|
||||
select * from t2;
|
||||
value64 value32
|
||||
9223372036854775807 4
|
||||
17156792991891826145 3
|
||||
select * from t1, t2 where t1.value64=17156792991891826145 and
|
||||
t2.value64=17156792991891826145;
|
||||
value64 value32 value64 value32
|
||||
17156792991891826145 1 17156792991891826145 3
|
||||
select * from t1, t2 where t1.value64=17156792991891826145 and
|
||||
t2.value64=t1.value64;
|
||||
value64 value32 value64 value32
|
||||
17156792991891826145 1 17156792991891826145 3
|
||||
select * from t1, t2 where t1.value64= 9223372036854775807 and
|
||||
t2.value64=9223372036854775807;
|
||||
value64 value32 value64 value32
|
||||
9223372036854775807 2 9223372036854775807 4
|
||||
select * from t1, t2 where t1.value64= 9223372036854775807 and
|
||||
t2.value64=t1.value64;
|
||||
value64 value32 value64 value32
|
||||
9223372036854775807 2 9223372036854775807 4
|
||||
drop table t1, t2;
|
||||
create table t1 select 1 as 'a';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(1) NOT NULL DEFAULT '0'
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 select 9223372036854775809 as 'a';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` bigint(19) unsigned NOT NULL DEFAULT '0'
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t1;
|
||||
a
|
||||
9223372036854775809
|
||||
drop table t1;
|
||||
DROP DATABASE IF EXISTS `scott`;
|
||||
Warnings:
|
||||
Note 1008 Can't drop database 'scott'; database doesn't exist
|
||||
create table t1 (a char(100), b varchar(100), c text, d blob);
|
||||
insert into t1 values(
|
||||
18446744073709551615,18446744073709551615,
|
||||
18446744073709551615, 18446744073709551615
|
||||
);
|
||||
insert into t1 values (-1 | 0,-1 | 0,-1 | 0 ,-1 | 0);
|
||||
select * from t1;
|
||||
a b c d
|
||||
18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
|
||||
18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
|
||||
drop table t1;
|
||||
create table t1 ( quantity decimal(2) unsigned);
|
||||
insert into t1 values (500), (-500), (~0), (-1);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'quantity' at row 1
|
||||
Warning 1264 Out of range value for column 'quantity' at row 2
|
||||
Warning 1264 Out of range value for column 'quantity' at row 3
|
||||
Warning 1264 Out of range value for column 'quantity' at row 4
|
||||
select * from t1;
|
||||
quantity
|
||||
99
|
||||
0
|
||||
99
|
||||
0
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
`col1` INT(1) NULL,
|
||||
`col2` INT(2) NULL,
|
||||
`col3` INT(3) NULL,
|
||||
`col4` INT(4) NULL,
|
||||
`col5` INT(5) NULL,
|
||||
`col6` INT(6) NULL,
|
||||
`col7` INT(7) NULL,
|
||||
`col8` INT(8) NULL,
|
||||
`col9` INT(9) NULL,
|
||||
`col10` BIGINT(10) NULL,
|
||||
`col11` BIGINT(11) NULL,
|
||||
`col12` BIGINT(12) NULL,
|
||||
`col13` BIGINT(13) NULL,
|
||||
`col14` BIGINT(14) NULL,
|
||||
`col15` BIGINT(15) NULL,
|
||||
`col16` BIGINT(16) NULL,
|
||||
`col17` BIGINT(17) NULL,
|
||||
`col18` BIGINT(18) NULL,
|
||||
`col19` DECIMAL(19, 0) NULL,
|
||||
`col20` DECIMAL(20, 0) NULL,
|
||||
`col21` DECIMAL(21, 0) NULL,
|
||||
`col22` DECIMAL(22, 0) NULL,
|
||||
`col23` DECIMAL(23, 0) NULL,
|
||||
`col24` DECIMAL(24, 0) NULL,
|
||||
`col25` DECIMAL(25, 0) NULL,
|
||||
`col26` DECIMAL(26, 0) NULL,
|
||||
`col27` DECIMAL(27, 0) NULL,
|
||||
`col28` DECIMAL(28, 0) NULL,
|
||||
`col29` DECIMAL(29, 0) NULL,
|
||||
`col30` DECIMAL(30, 0) NULL,
|
||||
`col31` DECIMAL(31, 0) NULL,
|
||||
`col32` DECIMAL(32, 0) NULL,
|
||||
`col33` DECIMAL(33, 0) NULL,
|
||||
`col34` DECIMAL(34, 0) NULL,
|
||||
`col35` DECIMAL(35, 0) NULL,
|
||||
`col36` DECIMAL(36, 0) NULL,
|
||||
`col37` DECIMAL(37, 0) NULL,
|
||||
`col38` DECIMAL(38, 0) NULL,
|
||||
`fix1` DECIMAL(38, 1) NULL,
|
||||
`fix2` DECIMAL(38, 2) NULL,
|
||||
`fix3` DECIMAL(38, 3) NULL,
|
||||
`fix4` DECIMAL(38, 4) NULL,
|
||||
`fix5` DECIMAL(38, 5) NULL,
|
||||
`fix6` DECIMAL(38, 6) NULL,
|
||||
`fix7` DECIMAL(38, 7) NULL,
|
||||
`fix8` DECIMAL(38, 8) NULL,
|
||||
`fix9` DECIMAL(38, 9) NULL,
|
||||
`fix10` DECIMAL(38, 10) NULL,
|
||||
`fix11` DECIMAL(38, 11) NULL,
|
||||
`fix12` DECIMAL(38, 12) NULL,
|
||||
`fix13` DECIMAL(38, 13) NULL,
|
||||
`fix14` DECIMAL(38, 14) NULL,
|
||||
`fix15` DECIMAL(38, 15) NULL,
|
||||
`fix16` DECIMAL(38, 16) NULL,
|
||||
`fix17` DECIMAL(38, 17) NULL,
|
||||
`fix18` DECIMAL(38, 18) NULL,
|
||||
`fix19` DECIMAL(38, 19) NULL,
|
||||
`fix20` DECIMAL(38, 20) NULL,
|
||||
`fix21` DECIMAL(38, 21) NULL,
|
||||
`fix22` DECIMAL(38, 22) NULL,
|
||||
`fix23` DECIMAL(38, 23) NULL,
|
||||
`fix24` DECIMAL(38, 24) NULL,
|
||||
`fix25` DECIMAL(38, 25) NULL,
|
||||
`fix26` DECIMAL(38, 26) NULL,
|
||||
`fix27` DECIMAL(38, 27) NULL,
|
||||
`fix28` DECIMAL(38, 28) NULL,
|
||||
`fix29` DECIMAL(38, 29) NULL,
|
||||
`fix30` DECIMAL(38, 30) NULL
|
||||
);
|
||||
INSERT INTO t1(`col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`, `col19`, `col20`, `col21`, `col22`, `col23`, `col24`, `col25`, `col26`, `col27`, `col28`, `col29`, `col30`, `col31`, `col32`, `col33`, `col34`, `col35`, `col36`, `col37`, `col38`, `fix1`, `fix2`, `fix3`, `fix4`, `fix5`, `fix6`, `fix7`, `fix8`, `fix9`, `fix10`, `fix11`, `fix12`, `fix13`, `fix14`, `fix15`, `fix16`, `fix17`, `fix18`, `fix19`, `fix20`, `fix21`, `fix22`, `fix23`, `fix24`, `fix25`, `fix26`, `fix27`, `fix28`, `fix29`, `fix30`)
|
||||
VALUES (9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999,
|
||||
9999999999, 99999999999, 999999999999, 9999999999999, 99999999999999,
|
||||
999999999999999, 9999999999999999, 99999999999999999, 999999999999999999,
|
||||
9999999999999999999, 99999999999999999999, 999999999999999999999,
|
||||
9999999999999999999999, 99999999999999999999999, 999999999999999999999999,
|
||||
9999999999999999999999999, 99999999999999999999999999,
|
||||
999999999999999999999999999, 9999999999999999999999999999,
|
||||
99999999999999999999999999999, 999999999999999999999999999999,
|
||||
9999999999999999999999999999999, 99999999999999999999999999999999,
|
||||
999999999999999999999999999999999, 9999999999999999999999999999999999,
|
||||
99999999999999999999999999999999999, 999999999999999999999999999999999999,
|
||||
9999999999999999999999999999999999999, 99999999999999999999999999999999999999,
|
||||
9999999999999999999999999999999999999.9,
|
||||
999999999999999999999999999999999999.99,
|
||||
99999999999999999999999999999999999.999,
|
||||
9999999999999999999999999999999999.9999,
|
||||
999999999999999999999999999999999.99999,
|
||||
99999999999999999999999999999999.999999,
|
||||
9999999999999999999999999999999.9999999,
|
||||
999999999999999999999999999999.99999999,
|
||||
99999999999999999999999999999.999999999,
|
||||
9999999999999999999999999999.9999999999,
|
||||
999999999999999999999999999.99999999999,
|
||||
99999999999999999999999999.999999999999,
|
||||
9999999999999999999999999.9999999999999,
|
||||
999999999999999999999999.99999999999999,
|
||||
99999999999999999999999.999999999999999,
|
||||
9999999999999999999999.9999999999999999,
|
||||
999999999999999999999.99999999999999999,
|
||||
99999999999999999999.999999999999999999,
|
||||
9999999999999999999.9999999999999999999,
|
||||
999999999999999999.99999999999999999999,
|
||||
99999999999999999.999999999999999999999,
|
||||
9999999999999999.9999999999999999999999,
|
||||
999999999999999.99999999999999999999999,
|
||||
99999999999999.999999999999999999999999,
|
||||
9999999999999.9999999999999999999999999,
|
||||
999999999999.99999999999999999999999999,
|
||||
99999999999.999999999999999999999999999,
|
||||
9999999999.9999999999999999999999999999,
|
||||
999999999.99999999999999999999999999999,
|
||||
99999999.999999999999999999999999999999);
|
||||
SELECT * FROM t1;
|
||||
col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 col13 col14 col15 col16 col17 col18 col19 col20 col21 col22 col23 col24 col25 col26 col27 col28 col29 col30 col31 col32 col33 col34 col35 col36 col37 col38 fix1 fix2 fix3 fix4 fix5 fix6 fix7 fix8 fix9 fix10 fix11 fix12 fix13 fix14 fix15 fix16 fix17 fix18 fix19 fix20 fix21 fix22 fix23 fix24 fix25 fix26 fix27 fix28 fix29 fix30
|
||||
9 99 999 9999 99999 999999 9999999 99999999 999999999 9999999999 99999999999 999999999999 9999999999999 99999999999999 999999999999999 9999999999999999 99999999999999999 999999999999999999 9999999999999999999 99999999999999999999 999999999999999999999 9999999999999999999999 99999999999999999999999 999999999999999999999999 9999999999999999999999999 99999999999999999999999999 999999999999999999999999999 9999999999999999999999999999 99999999999999999999999999999 999999999999999999999999999999 9999999999999999999999999999999 99999999999999999999999999999999 999999999999999999999999999999999 9999999999999999999999999999999999 99999999999999999999999999999999999 999999999999999999999999999999999999 9999999999999999999999999999999999999 99999999999999999999999999999999999999 9999999999999999999999999999999999999.9 999999999999999999999999999999999999.99 99999999999999999999999999999999999.999 9999999999999999999999999999999999.9999 999999999999999999999999999999999.99999 99999999999999999999999999999999.999999 9999999999999999999999999999999.9999999 999999999999999999999999999999.99999999 99999999999999999999999999999.999999999 9999999999999999999999999999.9999999999 999999999999999999999999999.99999999999 99999999999999999999999999.999999999999 9999999999999999999999999.9999999999999 999999999999999999999999.99999999999999 99999999999999999999999.999999999999999 9999999999999999999999.9999999999999999 999999999999999999999.99999999999999999 99999999999999999999.999999999999999999 9999999999999999999.9999999999999999999 999999999999999999.99999999999999999999 99999999999999999.999999999999999999999 9999999999999999.9999999999999999999999 999999999999999.99999999999999999999999 99999999999999.999999999999999999999999 9999999999999.9999999999999999999999999 999999999999.99999999999999999999999999 99999999999.999999999999999999999999999 9999999999.9999999999999999999999999999 999999999.99999999999999999999999999999 99999999.999999999999999999999999999999
|
||||
DROP TABLE t1;
|
||||
create table t1 (bigint_col bigint unsigned);
|
||||
insert into t1 values (17666000000000000000);
|
||||
select * from t1 where bigint_col=17666000000000000000;
|
||||
bigint_col
|
||||
17666000000000000000
|
||||
select * from t1 where bigint_col='17666000000000000000';
|
||||
bigint_col
|
||||
17666000000000000000
|
||||
drop table t1;
|
||||
|
||||
bug 19955 -- mod is signed with bigint
|
||||
select cast(10000002383263201056 as unsigned) mod 50 as result;
|
||||
result
|
||||
6
|
||||
create table t1 (c1 bigint unsigned);
|
||||
insert into t1 values (10000002383263201056);
|
||||
select c1 mod 50 as result from t1;
|
||||
result
|
||||
6
|
||||
drop table t1;
|
@ -1,162 +0,0 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (name char(20) not null, primary key (name));
|
||||
create table t2 (name char(20) binary not null, primary key (name));
|
||||
insert into t1 values ("å");
|
||||
insert into t1 values ("ä");
|
||||
insert into t1 values ("ö");
|
||||
insert into t2 select * from t1;
|
||||
select * from t1 order by name;
|
||||
name
|
||||
å
|
||||
ä
|
||||
ö
|
||||
select concat("*",name,"*") from t1 order by 1;
|
||||
concat("*",name,"*")
|
||||
*å*
|
||||
*ä*
|
||||
*ö*
|
||||
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1;
|
||||
min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*"))
|
||||
å *å* ö *ö*
|
||||
select * from t2 order by name;
|
||||
name
|
||||
ä
|
||||
å
|
||||
ö
|
||||
select concat("*",name,"*") from t2 order by 1;
|
||||
concat("*",name,"*")
|
||||
*ä*
|
||||
*å*
|
||||
*ö*
|
||||
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2;
|
||||
min(name) min(concat("*",name,"*")) max(name) max(concat("*",name,"*"))
|
||||
ä *ä* ö *ö*
|
||||
select name from t1 where name between 'Ä' and 'Ö';
|
||||
name
|
||||
ä
|
||||
ö
|
||||
select name from t2 where name between 'ä' and 'ö';
|
||||
name
|
||||
ä
|
||||
å
|
||||
ö
|
||||
select name from t2 where name between 'Ä' and 'Ö';
|
||||
name
|
||||
drop table t1,t2;
|
||||
create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b));
|
||||
insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
|
||||
select concat("-",a,"-",b,"-") from t1 where a="hello";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 where a="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 where b="hello";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 where b="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
|
||||
select concat("-",a,"-",b,"-") from t1;
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
-hello2-hello2-
|
||||
select concat("-",a,"-",b,"-") from t1 where b="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
|
||||
concat("-",a,"-",b,"-")
|
||||
-hello-hello-
|
||||
drop table t1;
|
||||
create table t1 (b char(8));
|
||||
insert into t1 values(NULL);
|
||||
select b from t1 where binary b like '';
|
||||
b
|
||||
select b from t1 group by binary b like '';
|
||||
b
|
||||
NULL
|
||||
select b from t1 having binary b like '';
|
||||
b
|
||||
drop table t1;
|
||||
create table t1 (a char(3) binary, b binary(3));
|
||||
insert into t1 values ('aaa','bbb'),('AAA','BBB');
|
||||
select upper(a),upper(b) from t1;
|
||||
upper(a) upper(b)
|
||||
AAA bbb
|
||||
AAA BBB
|
||||
select lower(a),lower(b) from t1;
|
||||
lower(a) lower(b)
|
||||
aaa bbb
|
||||
aaa BBB
|
||||
select * from t1 where upper(a)='AAA';
|
||||
a b
|
||||
aaa bbb
|
||||
AAA BBB
|
||||
select * from t1 where lower(a)='aaa';
|
||||
a b
|
||||
aaa bbb
|
||||
AAA BBB
|
||||
select * from t1 where upper(b)='BBB';
|
||||
a b
|
||||
AAA BBB
|
||||
select * from t1 where lower(b)='bbb';
|
||||
a b
|
||||
aaa bbb
|
||||
select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1;
|
||||
charset(a) charset(b) charset(binary 'ccc')
|
||||
latin1 binary binary
|
||||
select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
|
||||
collation(a) collation(b) collation(binary 'ccc')
|
||||
latin1_bin binary binary
|
||||
drop table t1;
|
||||
create table t1( firstname char(20), lastname char(20));
|
||||
insert into t1 values ("john","doe"),("John","Doe");
|
||||
select * from t1 where firstname='john' and firstname like binary 'john';
|
||||
firstname lastname
|
||||
john doe
|
||||
select * from t1 where firstname='john' and binary 'john' = firstname;
|
||||
firstname lastname
|
||||
john doe
|
||||
select * from t1 where firstname='john' and firstname = binary 'john';
|
||||
firstname lastname
|
||||
john doe
|
||||
select * from t1 where firstname='John' and firstname like binary 'john';
|
||||
firstname lastname
|
||||
john doe
|
||||
select * from t1 where firstname='john' and firstname like binary 'John';
|
||||
firstname lastname
|
||||
John Doe
|
||||
drop table t1;
|
||||
create table t1 (a binary);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` binary(1) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (col1 binary(4));
|
||||
insert into t1 values ('a'),('a ');
|
||||
select hex(col1) from t1;
|
||||
hex(col1)
|
||||
61000000
|
||||
61200000
|
||||
alter table t1 modify col1 binary(10);
|
||||
select hex(col1) from t1;
|
||||
hex(col1)
|
||||
61000000000000000000
|
||||
61200000000000000000
|
||||
insert into t1 values ('b'),('b ');
|
||||
select hex(col1) from t1;
|
||||
hex(col1)
|
||||
61000000000000000000
|
||||
61200000000000000000
|
||||
62000000000000000000
|
||||
62200000000000000000
|
||||
drop table t1;
|
@ -1,88 +0,0 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2);
|
||||
IF(NULL AND 1, 1, 2) IF(1 AND NULL, 1, 2)
|
||||
2 2
|
||||
SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0;
|
||||
NULL AND 1 1 AND NULL 0 AND NULL NULL and 0
|
||||
NULL NULL 0 0
|
||||
create table t1 (a int);
|
||||
insert into t1 values (0),(1),(NULL);
|
||||
SELECT * FROM t1 WHERE IF(a AND 1, 0, 1);
|
||||
a
|
||||
0
|
||||
NULL
|
||||
SELECT * FROM t1 WHERE IF(1 AND a, 0, 1);
|
||||
a
|
||||
0
|
||||
NULL
|
||||
SELECT * FROM t1 where NOT(a AND 1);
|
||||
a
|
||||
0
|
||||
SELECT * FROM t1 where NOT(1 AND a);
|
||||
a
|
||||
0
|
||||
SELECT * FROM t1 where (a AND 1)=0;
|
||||
a
|
||||
0
|
||||
SELECT * FROM t1 where (1 AND a)=0;
|
||||
a
|
||||
0
|
||||
SELECT * FROM t1 where (1 AND a)=1;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t1 where (1 AND a) IS NULL;
|
||||
a
|
||||
NULL
|
||||
set sql_mode='high_not_precedence';
|
||||
select * from t1 where not a between 2 and 3;
|
||||
a
|
||||
set sql_mode=default;
|
||||
select * from t1 where not a between 2 and 3;
|
||||
a
|
||||
0
|
||||
1
|
||||
select a, a is false, a is true, a is unknown from t1;
|
||||
a a is false a is true a is unknown
|
||||
0 1 0 0
|
||||
1 0 1 0
|
||||
NULL 0 0 1
|
||||
select a, a is not false, a is not true, a is not unknown from t1;
|
||||
a a is not false a is not true a is not unknown
|
||||
0 0 1 1
|
||||
1 1 0 1
|
||||
NULL 1 1 0
|
||||
SET @a=0, @b=0;
|
||||
SELECT * FROM t1 WHERE NULL AND (@a:=@a+1);
|
||||
a
|
||||
SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1));
|
||||
a
|
||||
SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
|
||||
a
|
||||
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
|
||||
a
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
|
||||
select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1;
|
||||
A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB
|
||||
N N N N N N N N N N
|
||||
0 N 1 N 0 1 1 N N N
|
||||
1 N 0 N N N N 1 0 0
|
||||
N 0 N 1 0 1 1 N N N
|
||||
N 1 N 0 N N N 1 0 0
|
||||
0 0 1 1 0 1 1 0 1 1
|
||||
0 1 1 0 0 1 1 1 0 0
|
||||
1 0 0 1 0 1 1 1 0 0
|
||||
1 1 0 0 1 0 0 1 0 0
|
||||
select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1;
|
||||
A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB
|
||||
N N N N N N N N N N
|
||||
0 N 1 N 0 1 1 N N N
|
||||
1 N 0 N N N N 1 0 0
|
||||
N 0 N 1 0 1 1 N N N
|
||||
N 1 N 0 N N N 1 0 0
|
||||
0 0 1 1 0 1 1 0 1 1
|
||||
0 1 1 0 0 1 1 1 0 0
|
||||
1 0 0 1 0 1 1 1 0 0
|
||||
1 1 0 0 1 0 0 1 0 0
|
||||
drop table t1;
|
@ -1,11 +0,0 @@
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1 (a int, unique (a), b int not null, unique(b), c int not null, index(c));
|
||||
replace into t1 values (1,1,1),(2,2,2),(3,1,3);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
2 2 2
|
||||
3 1 3
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
@ -1,202 +0,0 @@
|
||||
drop table if exists t1,t2;
|
||||
select CASE "b" when "a" then 1 when "b" then 2 END;
|
||||
CASE "b" when "a" then 1 when "b" then 2 END
|
||||
2
|
||||
select CASE "c" when "a" then 1 when "b" then 2 END;
|
||||
CASE "c" when "a" then 1 when "b" then 2 END
|
||||
NULL
|
||||
select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END;
|
||||
CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END
|
||||
3
|
||||
select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END;
|
||||
CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END
|
||||
ok
|
||||
select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
|
||||
CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END
|
||||
ok
|
||||
select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
|
||||
CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end
|
||||
a
|
||||
select CASE when 1=0 then "true" else "false" END;
|
||||
CASE when 1=0 then "true" else "false" END
|
||||
false
|
||||
select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
|
||||
CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END
|
||||
one
|
||||
explain extended select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select (case 1 when 1 then 'one' when 2 then 'two' else 'more' end) AS `CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END`
|
||||
select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
|
||||
CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END
|
||||
two
|
||||
select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
|
||||
(CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0
|
||||
2
|
||||
select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
|
||||
(CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0
|
||||
2.00
|
||||
select case 1/0 when "a" then "true" else "false" END;
|
||||
case 1/0 when "a" then "true" else "false" END
|
||||
false
|
||||
select case 1/0 when "a" then "true" END;
|
||||
case 1/0 when "a" then "true" END
|
||||
NULL
|
||||
select (case 1/0 when "a" then "true" END) | 0;
|
||||
(case 1/0 when "a" then "true" END) | 0
|
||||
NULL
|
||||
select (case 1/0 when "a" then "true" END) + 0.0;
|
||||
(case 1/0 when "a" then "true" END) + 0.0
|
||||
NULL
|
||||
select case when 1>0 then "TRUE" else "FALSE" END;
|
||||
case when 1>0 then "TRUE" else "FALSE" END
|
||||
TRUE
|
||||
select case when 1<0 then "TRUE" else "FALSE" END;
|
||||
case when 1<0 then "TRUE" else "FALSE" END
|
||||
FALSE
|
||||
create table t1 (a int);
|
||||
insert into t1 values(1),(2),(3),(4);
|
||||
select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
|
||||
fcase count(*)
|
||||
0 2
|
||||
2 1
|
||||
3 1
|
||||
explain extended select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using temporary; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select (case `test`.`t1`.`a` when 1 then 2 when 2 then 3 else 0 end) AS `fcase`,count(0) AS `count(*)` from `test`.`t1` group by (case `test`.`t1`.`a` when 1 then 2 when 2 then 3 else 0 end)
|
||||
select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase;
|
||||
fcase count(*)
|
||||
nothing 2
|
||||
one 1
|
||||
two 1
|
||||
drop table t1;
|
||||
create table t1 (row int not null, col int not null, val varchar(255) not null);
|
||||
insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
|
||||
select max(case col when 1 then val else null end) as color from t1 group by row;
|
||||
color
|
||||
orange
|
||||
yellow
|
||||
green
|
||||
drop table t1;
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1 SELECT
|
||||
CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1,
|
||||
CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2,
|
||||
CASE WHEN 1 THEN 'a' ELSE 1 END AS c3,
|
||||
CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
|
||||
CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
|
||||
CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
|
||||
CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
|
||||
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
|
||||
CASE WHEN 1 THEN 1.0 END AS c9,
|
||||
CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10,
|
||||
CASE WHEN 1 THEN 0.1e1 else 1 END AS c11,
|
||||
CASE WHEN 1 THEN 0.1e1 else '1' END AS c12
|
||||
;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
|
||||
`c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
|
||||
`c3` varchar(1) NOT NULL DEFAULT '',
|
||||
`c4` varchar(1) NOT NULL DEFAULT '',
|
||||
`c5` varchar(4) NOT NULL DEFAULT '',
|
||||
`c6` varchar(4) NOT NULL DEFAULT '',
|
||||
`c7` decimal(2,1) NOT NULL DEFAULT '0.0',
|
||||
`c8` decimal(2,1) NOT NULL DEFAULT '0.0',
|
||||
`c9` decimal(2,1) DEFAULT NULL,
|
||||
`c10` double NOT NULL DEFAULT '0',
|
||||
`c11` double NOT NULL DEFAULT '0',
|
||||
`c12` varchar(5) NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
SELECT CASE
|
||||
WHEN 1
|
||||
THEN _latin1'a' COLLATE latin1_danish_ci
|
||||
ELSE _latin1'a' COLLATE latin1_swedish_ci
|
||||
END;
|
||||
ERROR HY000: Illegal mix of collations (latin1_danish_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'case'
|
||||
SELECT CASE _latin1'a' COLLATE latin1_general_ci
|
||||
WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1
|
||||
WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2
|
||||
END;
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_danish_ci,EXPLICIT), (latin1_swedish_ci,EXPLICIT) for operation 'case'
|
||||
SELECT
|
||||
CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END,
|
||||
CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END,
|
||||
CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END,
|
||||
CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
|
||||
;
|
||||
CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
|
||||
1 2 1 2
|
||||
CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a');
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'coalesce'
|
||||
CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin);
|
||||
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
|
||||
CREATE TABLE t1 SELECT
|
||||
COALESCE(1), COALESCE(1.0),COALESCE('a'),
|
||||
COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
|
||||
COALESCE('a' COLLATE latin1_bin,'b');
|
||||
explain extended SELECT
|
||||
COALESCE(1), COALESCE(1.0),COALESCE('a'),
|
||||
COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
|
||||
COALESCE('a' COLLATE latin1_bin,'b');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce('a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,'1') AS `COALESCE(1,'1')`,coalesce(1.1,'1') AS `COALESCE(1.1,'1')`,coalesce(('a' collate latin1_bin),'b') AS `COALESCE('a' COLLATE latin1_bin,'b')`
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`COALESCE(1)` int(1) NOT NULL DEFAULT '0',
|
||||
`COALESCE(1.0)` decimal(2,1) NOT NULL DEFAULT '0.0',
|
||||
`COALESCE('a')` varchar(1) NOT NULL DEFAULT '',
|
||||
`COALESCE(1,1.0)` decimal(2,1) NOT NULL DEFAULT '0.0',
|
||||
`COALESCE(1,'1')` varchar(1) NOT NULL DEFAULT '',
|
||||
`COALESCE(1.1,'1')` varchar(4) NOT NULL DEFAULT '',
|
||||
`COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
SELECT 'case+union+test'
|
||||
UNION
|
||||
SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
|
||||
case+union+test
|
||||
case+union+test
|
||||
nobug
|
||||
SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
|
||||
CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END
|
||||
nobug
|
||||
SELECT 'case+union+test'
|
||||
UNION
|
||||
SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END;
|
||||
case+union+test
|
||||
case+union+test
|
||||
nobug
|
||||
create table t1(a float, b int default 3);
|
||||
insert into t1 (a) values (2), (11), (8);
|
||||
select min(a), min(case when 1=1 then a else NULL end),
|
||||
min(case when 1!=1 then NULL else a end)
|
||||
from t1 where b=3 group by b;
|
||||
min(a) min(case when 1=1 then a else NULL end) min(case when 1!=1 then NULL else a end)
|
||||
2 2 2
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (EMPNUM INT);
|
||||
INSERT INTO t1 VALUES (0), (2);
|
||||
CREATE TABLE t2 (EMPNUM DECIMAL (4, 2));
|
||||
INSERT INTO t2 VALUES (0.0), (9.0);
|
||||
SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
|
||||
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
|
||||
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
|
||||
CEMPNUM EMPMUM1 EMPNUM2
|
||||
0.00 0 0.00
|
||||
2.00 2 NULL
|
||||
SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
|
||||
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
|
||||
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
|
||||
CEMPNUM EMPMUM1 EMPNUM2
|
||||
0.00 0 0.00
|
||||
2.00 2 NULL
|
||||
DROP TABLE t1,t2;
|
@ -1,406 +0,0 @@
|
||||
select CAST(1-2 AS UNSIGNED);
|
||||
CAST(1-2 AS UNSIGNED)
|
||||
18446744073709551615
|
||||
Warnings:
|
||||
Note 1105 Cast to unsigned converted negative integer to it's positive complement
|
||||
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
|
||||
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
|
||||
-1
|
||||
Warnings:
|
||||
Note 1105 Cast to unsigned converted negative integer to it's positive complement
|
||||
select CAST('10 ' as unsigned integer);
|
||||
CAST('10 ' as unsigned integer)
|
||||
10
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '10 '
|
||||
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
|
||||
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
|
||||
18446744073709551611 18446744073709551611
|
||||
Warnings:
|
||||
Note 1105 Cast to unsigned converted negative integer to it's positive complement
|
||||
Note 1105 Cast to unsigned converted negative integer to it's positive complement
|
||||
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
|
||||
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
|
||||
18446744073709551610 18446744073709551612
|
||||
Warnings:
|
||||
Note 1105 Cast to unsigned converted negative integer to it's positive complement
|
||||
Note 1105 Cast to unsigned converted negative integer to it's positive complement
|
||||
select ~5, cast(~5 as signed);
|
||||
~5 cast(~5 as signed)
|
||||
18446744073709551610 -6
|
||||
explain extended select ~5, cast(~5 as signed);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as signed)`
|
||||
select cast(5 as unsigned) -6.0;
|
||||
cast(5 as unsigned) -6.0
|
||||
-1.0
|
||||
select cast(NULL as signed), cast(1/0 as signed);
|
||||
cast(NULL as signed) cast(1/0 as signed)
|
||||
NULL NULL
|
||||
select cast(NULL as unsigned), cast(1/0 as unsigned);
|
||||
cast(NULL as unsigned) cast(1/0 as unsigned)
|
||||
NULL NULL
|
||||
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
|
||||
cast("A" as binary) = "a" cast(BINARY "a" as CHAR) = "A"
|
||||
0 1
|
||||
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
|
||||
cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME)
|
||||
2001-01-01 2001-01-01 00:00:00
|
||||
select cast("1:2:3" as TIME);
|
||||
cast("1:2:3" as TIME)
|
||||
01:02:03
|
||||
select CONVERT("2004-01-22 21:45:33",DATE);
|
||||
CONVERT("2004-01-22 21:45:33",DATE)
|
||||
2004-01-22
|
||||
select 10+'10';
|
||||
10+'10'
|
||||
20
|
||||
select 10.0+'10';
|
||||
10.0+'10'
|
||||
20
|
||||
select 10E+0+'10';
|
||||
10E+0+'10'
|
||||
20
|
||||
select CONVERT(DATE "2004-01-22 21:45:33" USING latin1);
|
||||
CONVERT(DATE "2004-01-22 21:45:33" USING latin1)
|
||||
2004-01-22 21:45:33
|
||||
select CONVERT(DATE "2004-01-22 21:45:33",CHAR);
|
||||
CONVERT(DATE "2004-01-22 21:45:33",CHAR)
|
||||
2004-01-22 21:45:33
|
||||
select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
|
||||
CONVERT(DATE "2004-01-22 21:45:33",CHAR(4))
|
||||
2004
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33'
|
||||
select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4));
|
||||
CONVERT(DATE "2004-01-22 21:45:33",BINARY(4))
|
||||
2004
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
|
||||
select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4));
|
||||
CAST(DATE "2004-01-22 21:45:33" AS BINARY(4))
|
||||
2004
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
|
||||
select CAST(0xb3 as signed);
|
||||
CAST(0xb3 as signed)
|
||||
179
|
||||
select CAST(0x8fffffffffffffff as signed);
|
||||
CAST(0x8fffffffffffffff as signed)
|
||||
-8070450532247928833
|
||||
select CAST(0xffffffffffffffff as unsigned);
|
||||
CAST(0xffffffffffffffff as unsigned)
|
||||
18446744073709551615
|
||||
select CAST(0xfffffffffffffffe as signed);
|
||||
CAST(0xfffffffffffffffe as signed)
|
||||
-2
|
||||
select cast('-10a' as signed integer);
|
||||
cast('-10a' as signed integer)
|
||||
-10
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-10a'
|
||||
select cast('a10' as unsigned integer);
|
||||
cast('a10' as unsigned integer)
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: 'a10'
|
||||
select 10+'a';
|
||||
10+'a'
|
||||
10
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
select 10.0+cast('a' as decimal);
|
||||
10.0+cast('a' as decimal)
|
||||
10.0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DECIMAL value: 'a'
|
||||
select 10E+0+'a';
|
||||
10E+0+'a'
|
||||
10
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
select cast('18446744073709551616' as unsigned);
|
||||
cast('18446744073709551616' as unsigned)
|
||||
18446744073709551615
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '18446744073709551616'
|
||||
select cast('18446744073709551616' as signed);
|
||||
cast('18446744073709551616' as signed)
|
||||
-1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '18446744073709551616'
|
||||
select cast('9223372036854775809' as signed);
|
||||
cast('9223372036854775809' as signed)
|
||||
-9223372036854775807
|
||||
Warnings:
|
||||
Note 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
||||
select cast('-1' as unsigned);
|
||||
cast('-1' as unsigned)
|
||||
18446744073709551615
|
||||
Warnings:
|
||||
Note 1105 Cast to unsigned converted negative integer to it's positive complement
|
||||
select cast('abc' as signed);
|
||||
cast('abc' as signed)
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: 'abc'
|
||||
select cast('1a' as signed);
|
||||
cast('1a' as signed)
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1a'
|
||||
select cast('' as signed);
|
||||
cast('' as signed)
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: ''
|
||||
set names binary;
|
||||
select cast(_latin1'test' as char character set latin2);
|
||||
cast(_latin1'test' as char character set latin2)
|
||||
test
|
||||
select cast(_koi8r'ÔÅÓÔ' as char character set cp1251);
|
||||
cast(_koi8r'ÔÅÓÔ' as char character set cp1251)
|
||||
òåñò
|
||||
create table t1 select cast(_koi8r'ÔÅÓÔ' as char character set cp1251) as t;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`t` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
select
|
||||
cast(_latin1'ab' AS char) as c1,
|
||||
cast(_latin1'a ' AS char) as c2,
|
||||
cast(_latin1'abc' AS char(2)) as c3,
|
||||
cast(_latin1'a ' AS char(2)) as c4,
|
||||
hex(cast(_latin1'a' AS char(2))) as c5;
|
||||
c1 c2 c3 c4 c5
|
||||
ab a ab a 6100
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'abc'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'a '
|
||||
select cast(1000 as CHAR(3));
|
||||
cast(1000 as CHAR(3))
|
||||
100
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(3) value: '1000'
|
||||
create table t1 select
|
||||
cast(_latin1'ab' AS char) as c1,
|
||||
cast(_latin1'a ' AS char) as c2,
|
||||
cast(_latin1'abc' AS char(2)) as c3,
|
||||
cast(_latin1'a ' AS char(2)) as c4,
|
||||
cast(_latin1'a' AS char(2)) as c5;
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'abc'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'a '
|
||||
select c1,c2,c3,c4,hex(c5) from t1;
|
||||
c1 c2 c3 c4 hex(c5)
|
||||
ab a ab a 6100
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` varbinary(2) NOT NULL DEFAULT '',
|
||||
`c2` varbinary(2) NOT NULL DEFAULT '',
|
||||
`c3` varbinary(2) NOT NULL DEFAULT '',
|
||||
`c4` varbinary(2) NOT NULL DEFAULT '',
|
||||
`c5` varbinary(2) NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
select
|
||||
cast(_koi8r'ÆÇ' AS nchar) as c1,
|
||||
cast(_koi8r'Æ ' AS nchar) as c2,
|
||||
cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3,
|
||||
cast(_koi8r'Æ ' AS nchar(2)) as c4,
|
||||
cast(_koi8r'Æ' AS nchar(2)) as c5;
|
||||
c1 c2 c3 c4 c5
|
||||
фг ф фг ф ф
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect CHAR(4) value: 'фгх'
|
||||
Warning 1292 Truncated incorrect CHAR(3) value: 'Ñ„ '
|
||||
create table t1 select
|
||||
cast(_koi8r'ÆÇ' AS nchar) as c1,
|
||||
cast(_koi8r'Æ ' AS nchar) as c2,
|
||||
cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3,
|
||||
cast(_koi8r'Æ ' AS nchar(2)) as c4,
|
||||
cast(_koi8r'Æ' AS nchar(2)) as c5;
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect CHAR(4) value: 'фгх'
|
||||
Warning 1292 Truncated incorrect CHAR(3) value: 'Ñ„ '
|
||||
select * from t1;
|
||||
c1 c2 c3 c4 c5
|
||||
фг ф фг ф ф
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`c2` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`c3` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`c4` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`c5` varchar(2) CHARACTER SET utf8 NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a binary(4), b char(4) character set koi8r);
|
||||
insert into t1 values (_binary'ÔÅÓÔ',_binary'ÔÅÓÔ');
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
a b cast(a as char character set cp1251) cast(b as binary)
|
||||
ÔÅÓÔ ÔÅÓÔ ÔÅÓÔ ÔÅÓÔ
|
||||
set names koi8r;
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
a b cast(a as char character set cp1251) cast(b as binary)
|
||||
ÔÅÓÔ ÔÅÓÔ æåõæ ÔÅÓÔ
|
||||
set names cp1251;
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
a b cast(a as char character set cp1251) cast(b as binary)
|
||||
ÔÅÓÔ òåñò ÔÅÓÔ ÔÅÓÔ
|
||||
drop table t1;
|
||||
set names binary;
|
||||
select cast("2001-1-1" as date) = "2001-01-01";
|
||||
cast("2001-1-1" as date) = "2001-01-01"
|
||||
1
|
||||
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
|
||||
cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
|
||||
1
|
||||
select cast("1:2:3" as TIME) = "1:02:03";
|
||||
cast("1:2:3" as TIME) = "1:02:03"
|
||||
1
|
||||
select cast(NULL as DATE);
|
||||
cast(NULL as DATE)
|
||||
NULL
|
||||
select cast(NULL as BINARY);
|
||||
cast(NULL as BINARY)
|
||||
NULL
|
||||
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
|
||||
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
|
||||
SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
|
||||
a CAST(a AS CHAR)
|
||||
aac aac
|
||||
aab aab
|
||||
aaa aaa
|
||||
SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a;
|
||||
a CAST(a AS CHAR(3))
|
||||
aac aac
|
||||
aab aab
|
||||
aaa aaa
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aaa'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aab'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aac'
|
||||
SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ;
|
||||
a CAST(a AS UNSIGNED)
|
||||
aaa 3
|
||||
aab 2
|
||||
aac 1
|
||||
SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a;
|
||||
a CAST(a AS CHAR(2))
|
||||
aaa aa
|
||||
aab aa
|
||||
aac aa
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aaa'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aab'
|
||||
Warning 1292 Truncated incorrect BINARY(2) value: 'aac'
|
||||
DROP TABLE t1;
|
||||
select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour);
|
||||
date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour)
|
||||
2004-12-30 00:00:00
|
||||
select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00');
|
||||
timediff(cast('2004-12-30 12:00:00' as time), '12:00:00')
|
||||
00:00:00
|
||||
select timediff(cast('1 12:00:00' as time), '12:00:00');
|
||||
timediff(cast('1 12:00:00' as time), '12:00:00')
|
||||
24:00:00
|
||||
select cast(18446744073709551615 as unsigned);
|
||||
cast(18446744073709551615 as unsigned)
|
||||
18446744073709551615
|
||||
select cast(18446744073709551615 as signed);
|
||||
cast(18446744073709551615 as signed)
|
||||
-1
|
||||
select cast('18446744073709551615' as unsigned);
|
||||
cast('18446744073709551615' as unsigned)
|
||||
18446744073709551615
|
||||
select cast('18446744073709551615' as signed);
|
||||
cast('18446744073709551615' as signed)
|
||||
-1
|
||||
Warnings:
|
||||
Note 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
||||
select cast('9223372036854775807' as signed);
|
||||
cast('9223372036854775807' as signed)
|
||||
9223372036854775807
|
||||
select cast(concat('184467440','73709551615') as unsigned);
|
||||
cast(concat('184467440','73709551615') as unsigned)
|
||||
18446744073709551615
|
||||
select cast(concat('184467440','73709551615') as signed);
|
||||
cast(concat('184467440','73709551615') as signed)
|
||||
-1
|
||||
Warnings:
|
||||
Note 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
||||
select cast(repeat('1',20) as unsigned);
|
||||
cast(repeat('1',20) as unsigned)
|
||||
11111111111111111111
|
||||
select cast(repeat('1',20) as signed);
|
||||
cast(repeat('1',20) as signed)
|
||||
-7335632962598440505
|
||||
Warnings:
|
||||
Note 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
||||
select cast(1.0e+300 as signed int);
|
||||
cast(1.0e+300 as signed int)
|
||||
9223372036854775807
|
||||
CREATE TABLE t1 (f1 double);
|
||||
INSERT INTO t1 SET f1 = -1.0e+30 ;
|
||||
INSERT INTO t1 SET f1 = +1.0e+30 ;
|
||||
SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
|
||||
double_val cast_val
|
||||
-1e30 -9223372036854775808
|
||||
1e30 9223372036854775807
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1e30'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1e30'
|
||||
DROP TABLE t1;
|
||||
select cast('1.2' as decimal(3,2));
|
||||
cast('1.2' as decimal(3,2))
|
||||
1.20
|
||||
select 1e18 * cast('1.2' as decimal(3,2));
|
||||
1e18 * cast('1.2' as decimal(3,2))
|
||||
1.2e18
|
||||
select cast(cast('1.2' as decimal(3,2)) as signed);
|
||||
cast(cast('1.2' as decimal(3,2)) as signed)
|
||||
1
|
||||
set @v1=1e18;
|
||||
select cast(@v1 as decimal(22, 2));
|
||||
cast(@v1 as decimal(22, 2))
|
||||
1000000000000000000.00
|
||||
select cast(-1e18 as decimal(22,2));
|
||||
cast(-1e18 as decimal(22,2))
|
||||
-1000000000000000000.00
|
||||
create table t1(s1 time);
|
||||
insert into t1 values ('11:11:11');
|
||||
select cast(s1 as decimal(7,2)) from t1;
|
||||
cast(s1 as decimal(7,2))
|
||||
99999.99
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'cast(s1 as decimal(7,2))' at row 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (v varchar(10), tt tinytext, t text,
|
||||
mt mediumtext, lt longtext);
|
||||
INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05');
|
||||
SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
|
||||
CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
|
||||
CAST(v AS DECIMAL) CAST(tt AS DECIMAL) CAST(t AS DECIMAL) CAST(mt AS DECIMAL) CAST(lt AS DECIMAL)
|
||||
1 2 3 4 5
|
||||
DROP TABLE t1;
|
||||
select cast(NULL as decimal(6)) as t1;
|
||||
t1
|
||||
NULL
|
||||
set names latin1;
|
||||
select hex(cast('a' as char(2) binary));
|
||||
hex(cast('a' as char(2) binary))
|
||||
61
|
||||
select hex(cast('a' as binary(2)));
|
||||
hex(cast('a' as binary(2)))
|
||||
6100
|
||||
select hex(cast('a' as char(2) binary));
|
||||
hex(cast('a' as char(2) binary))
|
||||
61
|
||||
End of 5.0 tests
|
@ -1,16 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1(n int not null, key(n), key(n), key(n), key(n));
|
||||
check table t1 extended;
|
||||
insert into t1 values (200000);
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
Create table t1(f1 int);
|
||||
Create table t2(f1 int);
|
||||
Create view v1 as Select * from t1;
|
||||
Check Table v1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.v1 check status OK
|
||||
test.t2 check status OK
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
@ -1,74 +0,0 @@
|
||||
create table t1 (
|
||||
`a&b` int,
|
||||
`a<b` int,
|
||||
`a>b` text
|
||||
);
|
||||
insert into t1 values (1, 2, 'a&b a<b a>b');
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select * from t1
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="a&b">1</field>
|
||||
<field name="a<b">2</field>
|
||||
<field name="a>b">a&b a<b a>b</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<database name="test">
|
||||
<table_structure name="t1">
|
||||
<field Field="a&b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
|
||||
<field Field="a<b" Type="int(11)" Null="YES" Key="" Extra="" Comment="" />
|
||||
<field Field="a>b" Type="text" Null="YES" Key="" Extra="" Comment="" />
|
||||
</table_structure>
|
||||
<table_data name="t1">
|
||||
<row>
|
||||
<field name="a&b">1</field>
|
||||
<field name="a<b">2</field>
|
||||
<field name="a>b">a&b a<b a>b</field>
|
||||
</row>
|
||||
</table_data>
|
||||
</database>
|
||||
</mysqldump>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select count(*) from t1
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="count(*)">1</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select 1 < 2 from dual
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="1 < 2">1</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select 1 > 2 from dual
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="1 > 2">0</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select 1 & 3 from dual
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="1 & 3">1</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="select null from dual
|
||||
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="NULL" xsi:nil="true" />
|
||||
</row>
|
||||
</resultset>
|
||||
drop table t1;
|
@ -1,28 +0,0 @@
|
||||
select 1+2/*hello*/+3;
|
||||
1+2/*hello*/+3
|
||||
6
|
||||
select 1 /* long
|
||||
multi line comment */;
|
||||
1
|
||||
1
|
||||
;
|
||||
ERROR 42000: Query was empty
|
||||
select 1 /*!32301 +1 */;
|
||||
1 +1
|
||||
2
|
||||
select 1 /*!52301 +1 */;
|
||||
1
|
||||
1
|
||||
select 1--1;
|
||||
1--1
|
||||
2
|
||||
select 1 --2
|
||||
+1;
|
||||
1 --2
|
||||
+1
|
||||
4
|
||||
select 1 # The rest of the row will be ignored
|
||||
;
|
||||
1
|
||||
1
|
||||
/* line with only comment */;
|
@ -1,55 +0,0 @@
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
|
||||
insert into t1 values ('000000000001'),('000000000002');
|
||||
explain select * from t1 where id=000000000001;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 12 NULL 2 Using where; Using index
|
||||
select * from t1 where id=000000000001;
|
||||
id
|
||||
000000000001
|
||||
delete from t1 where id=000000000002;
|
||||
select * from t1;
|
||||
id
|
||||
000000000001
|
||||
drop table t1;
|
||||
SELECT 'a' = 'a ';
|
||||
'a' = 'a '
|
||||
1
|
||||
SELECT 'a\0' < 'a';
|
||||
'a\0' < 'a'
|
||||
1
|
||||
SELECT 'a\0' < 'a ';
|
||||
'a\0' < 'a '
|
||||
1
|
||||
SELECT 'a\t' < 'a';
|
||||
'a\t' < 'a'
|
||||
1
|
||||
SELECT 'a\t' < 'a ';
|
||||
'a\t' < 'a '
|
||||
1
|
||||
CREATE TABLE t1 (a char(10) not null);
|
||||
INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
|
||||
SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
|
||||
hex(a) STRCMP(a,'a') STRCMP(a,'a ')
|
||||
61 0 0
|
||||
6100 -1 -1
|
||||
6109 -1 -1
|
||||
61 0 0
|
||||
DROP TABLE t1;
|
||||
SELECT CHAR(31) = '', '' = CHAR(31);
|
||||
CHAR(31) = '' '' = CHAR(31)
|
||||
0 0
|
||||
SELECT CHAR(30) = '', '' = CHAR(30);
|
||||
CHAR(30) = '' '' = CHAR(30)
|
||||
0 0
|
||||
create table t1 (a tinyint(1),b binary(1));
|
||||
insert into t1 values (0x01,0x01);
|
||||
select * from t1 where a=b;
|
||||
a b
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '\x01'
|
||||
select * from t1 where a=b and b=0x01;
|
||||
a b
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: '\x01'
|
||||
drop table if exists t1;
|
@ -1,120 +0,0 @@
|
||||
drop table if exists t1,t2;
|
||||
show tables;
|
||||
Tables_in_mysql
|
||||
columns_priv
|
||||
db
|
||||
event
|
||||
func
|
||||
general_log
|
||||
help_category
|
||||
help_keyword
|
||||
help_relation
|
||||
help_topic
|
||||
host
|
||||
ndb_binlog_index
|
||||
plugin
|
||||
proc
|
||||
procs_priv
|
||||
proxies_priv
|
||||
servers
|
||||
slow_log
|
||||
tables_priv
|
||||
time_zone
|
||||
time_zone_leap_second
|
||||
time_zone_name
|
||||
time_zone_transition
|
||||
time_zone_transition_type
|
||||
user
|
||||
show tables;
|
||||
Tables_in_test
|
||||
connect(localhost,root,z,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
|
||||
connect(localhost,root,z,test,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
|
||||
grant ALL on *.* to test@localhost identified by "gambling";
|
||||
grant ALL on *.* to test@127.0.0.1 identified by "gambling";
|
||||
show tables;
|
||||
Tables_in_mysql
|
||||
columns_priv
|
||||
db
|
||||
event
|
||||
func
|
||||
general_log
|
||||
help_category
|
||||
help_keyword
|
||||
help_relation
|
||||
help_topic
|
||||
host
|
||||
ndb_binlog_index
|
||||
plugin
|
||||
proc
|
||||
procs_priv
|
||||
proxies_priv
|
||||
servers
|
||||
slow_log
|
||||
tables_priv
|
||||
time_zone
|
||||
time_zone_leap_second
|
||||
time_zone_name
|
||||
time_zone_transition
|
||||
time_zone_transition_type
|
||||
user
|
||||
show tables;
|
||||
Tables_in_test
|
||||
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
|
||||
connect(localhost,,,,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user ''@'localhost' (using password: NO)
|
||||
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
|
||||
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
|
||||
update mysql.user set password=old_password("gambling2") where user=_binary"test";
|
||||
flush privileges;
|
||||
set password="";
|
||||
set password='gambling3';
|
||||
ERROR HY000: Password hash should be a 41-digit hexadecimal number
|
||||
set password=old_password('gambling3');
|
||||
show tables;
|
||||
Tables_in_mysql
|
||||
columns_priv
|
||||
db
|
||||
event
|
||||
func
|
||||
general_log
|
||||
help_category
|
||||
help_keyword
|
||||
help_relation
|
||||
help_topic
|
||||
host
|
||||
ndb_binlog_index
|
||||
plugin
|
||||
proc
|
||||
procs_priv
|
||||
proxies_priv
|
||||
servers
|
||||
slow_log
|
||||
tables_priv
|
||||
time_zone
|
||||
time_zone_leap_second
|
||||
time_zone_name
|
||||
time_zone_transition
|
||||
time_zone_transition_type
|
||||
user
|
||||
show tables;
|
||||
Tables_in_test
|
||||
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
|
||||
connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
|
||||
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
|
||||
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
|
||||
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
|
||||
delete from mysql.user where user=_binary"test";
|
||||
flush privileges;
|
||||
create table t1 (id integer not null auto_increment primary key);
|
||||
create temporary table t2(id integer not null auto_increment primary key);
|
||||
set @id := 1;
|
||||
delete from t1 where id like @id;
|
||||
drop table t1;
|
@ -1,19 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a int);
|
||||
insert t1 values (1);
|
||||
drop table t1;
|
||||
create table t1 (a int) engine=innodb;
|
||||
start transaction with consistent snapshot;
|
||||
insert into t1 values(1);
|
||||
select * from t1;
|
||||
a
|
||||
commit;
|
||||
delete from t1;
|
||||
start transaction;
|
||||
insert into t1 values(1);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
commit;
|
||||
drop table t1;
|
||||
drop database pbxt;
|
@ -1,29 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a int check (a>0));
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (0);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int, check (a>b));
|
||||
insert into t1 values (1,0);
|
||||
insert into t1 values (0,1);
|
||||
drop table t1;
|
||||
create table t1 (a int ,b int, constraint abc check (a>b));
|
||||
insert into t1 values (1,0);
|
||||
insert into t1 values (0,1);
|
||||
drop table t1;
|
||||
create table t1 (a int null);
|
||||
insert into t1 values (1),(NULL);
|
||||
drop table t1;
|
||||
create table t1 (a int null);
|
||||
alter table t1 add constraint constraint_1 unique (a);
|
||||
alter table t1 add constraint unique key_1(a);
|
||||
alter table t1 add constraint constraint_2 unique key_2(a);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
UNIQUE KEY `constraint_1` (`a`),
|
||||
UNIQUE KEY `key_1` (`a`),
|
||||
UNIQUE KEY `key_2` (`a`)
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
@ -1,5 +0,0 @@
|
||||
SHOW CONTRIBUTORS;
|
||||
Name Location Comment
|
||||
Ronald Bradford Brisbane, Australia EFF contribution for UC2006 Auction
|
||||
Sheeri Kritzer Boston, Mass. USA EFF contribution for UC2006 Auction
|
||||
Mark Shuttleworth London, UK. EFF contribution for UC2006 Auction
|
@ -1,68 +0,0 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (libname varchar(21) not null, city text, primary key (libname));
|
||||
create table t2 (isbn varchar(21) not null, author text, title text, primary key (isbn));
|
||||
create table t3 (isbn varchar(21) not null, libname varchar(21) not null, quantity int ,primary key (isbn,libname));
|
||||
insert into t2 values ('001','Daffy','A duck''s life');
|
||||
insert into t2 values ('002','Bugs','A rabbit\'s life');
|
||||
insert into t2 values ('003','Cowboy','Life on the range');
|
||||
insert into t2 values ('000','Anonymous','Wanna buy this book?');
|
||||
insert into t2 values ('004','Best Seller','One Heckuva book');
|
||||
insert into t2 values ('005','EveryoneBuys','This very book');
|
||||
insert into t2 values ('006','San Fran','It is a san fran lifestyle');
|
||||
insert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');
|
||||
insert into t3 values('000','New York Public Libra','1');
|
||||
insert into t3 values('001','New York Public Libra','2');
|
||||
insert into t3 values('002','New York Public Libra','3');
|
||||
insert into t3 values('003','New York Public Libra','4');
|
||||
insert into t3 values('004','New York Public Libra','5');
|
||||
insert into t3 values('005','New York Public Libra','6');
|
||||
insert into t3 values('006','San Fransisco Public','5');
|
||||
insert into t3 values('007','Berkeley Public1','3');
|
||||
insert into t3 values('007','Berkeley Public2','3');
|
||||
insert into t3 values('001','NYC Lib','8');
|
||||
insert into t1 values ('New York Public Libra','New York');
|
||||
insert into t1 values ('San Fransisco Public','San Fran');
|
||||
insert into t1 values ('Berkeley Public1','Berkeley');
|
||||
insert into t1 values ('Berkeley Public2','Berkeley');
|
||||
insert into t1 values ('NYC Lib','New York');
|
||||
select t2.isbn,city,t1.libname,count(t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city,t1.libname;
|
||||
isbn city libname a
|
||||
007 Berkeley Berkeley Public1 1
|
||||
007 Berkeley Berkeley Public2 1
|
||||
000 New York New York Public Libra 6
|
||||
001 New York NYC Lib 1
|
||||
006 San Fran San Fransisco Public 1
|
||||
select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct t1.libname) > 1;
|
||||
isbn city libname a
|
||||
007 Berkeley Berkeley Public1 2
|
||||
000 New York New York Public Libra 2
|
||||
select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct concat(t1.libname,'a')) > 1;
|
||||
isbn city libname a
|
||||
007 Berkeley Berkeley Public1 2
|
||||
000 New York New York Public Libra 2
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (f1 int);
|
||||
insert into t1 values (1);
|
||||
create table t2 (f1 int,f2 int);
|
||||
select t1.f1,count(distinct t2.f2),count(distinct 1,NULL) from t1 left join t2 on t1.f1=t2.f1 group by t1.f1;
|
||||
f1 count(distinct t2.f2) count(distinct 1,NULL)
|
||||
1 0 0
|
||||
drop table t1,t2;
|
||||
create table t1 (f int);
|
||||
select count(distinct f) from t1;
|
||||
count(distinct f)
|
||||
0
|
||||
drop table t1;
|
||||
create table t1 (a char(3), b char(20), primary key (a, b));
|
||||
insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English');
|
||||
select count(distinct a) from t1 group by b;
|
||||
count(distinct a)
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (f1 int, f2 int);
|
||||
insert into t1 values (0,1),(1,2);
|
||||
select count(distinct if(f1,3,f2)) from t1;
|
||||
count(distinct if(f1,3,f2))
|
||||
2
|
||||
drop table t1;
|
@ -1,129 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text);
|
||||
insert into t1 values (1,11, 'one','eleven', 'eleven'),
|
||||
(1,11, 'one','eleven', 'eleven'),
|
||||
(2,11, 'two','eleven', 'eleven'),
|
||||
(2,12, 'two','twevle', 'twelve'),
|
||||
(2,13, 'two','thirteen', 'foo'),
|
||||
(2,13, 'two','thirteen', 'foo'),
|
||||
(2,13, 'two','thirteen', 'bar'),
|
||||
(NULL,13, 'two','thirteen', 'bar'),
|
||||
(2,NULL, 'two','thirteen', 'bar'),
|
||||
(2,13, NULL,'thirteen', 'bar'),
|
||||
(2,13, 'two',NULL, 'bar'),
|
||||
(2,13, 'two','thirteen', NULL);
|
||||
select distinct n1 from t1;
|
||||
n1
|
||||
1
|
||||
2
|
||||
NULL
|
||||
select count(distinct n1) from t1;
|
||||
count(distinct n1)
|
||||
2
|
||||
select distinct n2 from t1;
|
||||
n2
|
||||
11
|
||||
12
|
||||
13
|
||||
NULL
|
||||
select count(distinct n2) from t1;
|
||||
count(distinct n2)
|
||||
3
|
||||
select distinct s from t1;
|
||||
s
|
||||
one
|
||||
two
|
||||
NULL
|
||||
select count(distinct s) from t1;
|
||||
count(distinct s)
|
||||
2
|
||||
select distinct vs from t1;
|
||||
vs
|
||||
eleven
|
||||
twevle
|
||||
thirteen
|
||||
NULL
|
||||
select count(distinct vs) from t1;
|
||||
count(distinct vs)
|
||||
3
|
||||
select distinct t from t1;
|
||||
t
|
||||
eleven
|
||||
twelve
|
||||
foo
|
||||
bar
|
||||
NULL
|
||||
select count(distinct t) from t1;
|
||||
count(distinct t)
|
||||
4
|
||||
select distinct n1,n2 from t1;
|
||||
n1 n2
|
||||
1 11
|
||||
2 11
|
||||
2 12
|
||||
2 13
|
||||
NULL 13
|
||||
2 NULL
|
||||
select count(distinct n1,n2) from t1;
|
||||
count(distinct n1,n2)
|
||||
4
|
||||
select distinct n1,s from t1;
|
||||
n1 s
|
||||
1 one
|
||||
2 two
|
||||
NULL two
|
||||
2 NULL
|
||||
select count(distinct n1,s) from t1;
|
||||
count(distinct n1,s)
|
||||
2
|
||||
select distinct s,n1,vs from t1;
|
||||
s n1 vs
|
||||
one 1 eleven
|
||||
two 2 eleven
|
||||
two 2 twevle
|
||||
two 2 thirteen
|
||||
two NULL thirteen
|
||||
NULL 2 thirteen
|
||||
two 2 NULL
|
||||
select count(distinct s,n1,vs) from t1;
|
||||
count(distinct s,n1,vs)
|
||||
4
|
||||
select distinct s,t from t1;
|
||||
s t
|
||||
one eleven
|
||||
two eleven
|
||||
two twelve
|
||||
two foo
|
||||
two bar
|
||||
NULL bar
|
||||
two NULL
|
||||
select count(distinct s,t) from t1;
|
||||
count(distinct s,t)
|
||||
5
|
||||
select count(distinct n1), count(distinct n2) from t1;
|
||||
count(distinct n1) count(distinct n2)
|
||||
2 3
|
||||
select count(distinct n2), n1 from t1 group by n1;
|
||||
count(distinct n2) n1
|
||||
1 NULL
|
||||
1 1
|
||||
3 2
|
||||
drop table t1;
|
||||
create table t1 (n int default NULL);
|
||||
flush status;
|
||||
select count(distinct n) from t1;
|
||||
count(distinct n)
|
||||
5000
|
||||
show status like 'Created_tmp_disk_tables';
|
||||
Variable_name Value
|
||||
Created_tmp_disk_tables 0
|
||||
drop table t1;
|
||||
create table t1 (s text);
|
||||
flush status;
|
||||
select count(distinct s) from t1;
|
||||
count(distinct s)
|
||||
5000
|
||||
show status like 'Created_tmp_disk_tables';
|
||||
Variable_name Value
|
||||
Created_tmp_disk_tables 1
|
||||
drop table t1;
|
@ -1,8 +0,0 @@
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
4181000
|
||||
SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
|
||||
DROP TABLE t1;
|
||||
set @@read_buffer_size=default;
|
File diff suppressed because it is too large
Load Diff
@ -1,536 +0,0 @@
|
||||
drop table if exists t1;
|
||||
SELECT variable_name, variable_value
|
||||
FROM information_schema.global_variables
|
||||
WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
|
||||
ORDER BY variable_name;
|
||||
variable_name variable_value
|
||||
DATETIME_FORMAT %Y-%m-%d %H:%i:%s
|
||||
DATE_FORMAT %Y-%m-%d
|
||||
TIME_FORMAT %H:%i:%s
|
||||
SELECT variable_name, variable_value
|
||||
FROM information_schema.session_variables
|
||||
WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
|
||||
ORDER BY variable_name;
|
||||
variable_name variable_value
|
||||
DATETIME_FORMAT %Y-%m-%d %H:%i:%s
|
||||
DATE_FORMAT %Y-%m-%d
|
||||
TIME_FORMAT %H:%i:%s
|
||||
select str_to_date(concat('15-01-2001',' 2:59:58.999'),
|
||||
concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
|
||||
str_to_date(concat('15-01-2001',' 2:59:58.999'),
|
||||
concat('%d-%m-%Y',' ','%H:%i:%s.%f'))
|
||||
2001-01-15 02:59:58.999000
|
||||
select STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T');
|
||||
STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T')
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1411 Incorrect time value: '22.30.61' for function str_to_date
|
||||
create table t1 (date char(30), format char(30) not null);
|
||||
insert into t1 values
|
||||
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
|
||||
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
|
||||
('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
|
||||
('03-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
|
||||
('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
|
||||
('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
|
||||
('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
|
||||
('2003-01-02 12:11:12.12345 am', '%Y-%m-%d %h:%i:%S.%f%p'),
|
||||
('2003-01-02 11:11:12Pm', '%Y-%m-%d %h:%i:%S%p'),
|
||||
('10:20:10', '%H:%i:%s'),
|
||||
('10:20:10', '%h:%i:%s.%f'),
|
||||
('10:20:10', '%T'),
|
||||
('10:20:10AM', '%h:%i:%s%p'),
|
||||
('10:20:10AM', '%r'),
|
||||
('10:20:10.44AM', '%h:%i:%s.%f%p'),
|
||||
('15-01-2001 12:59:58', '%d-%m-%Y %H:%i:%S'),
|
||||
('15 September 2001', '%d %M %Y'),
|
||||
('15 SEPTEMB 2001', '%d %M %Y'),
|
||||
('15 MAY 2001', '%d %b %Y'),
|
||||
('15th May 2001', '%D %b %Y'),
|
||||
('Sunday 15 MAY 2001', '%W %d %b %Y'),
|
||||
('Sund 15 MAY 2001', '%W %d %b %Y'),
|
||||
('Tuesday 00 2002', '%W %U %Y'),
|
||||
('Thursday 53 1998', '%W %u %Y'),
|
||||
('Sunday 01 2001', '%W %v %x'),
|
||||
('Tuesday 52 2001', '%W %V %X'),
|
||||
('060 2004', '%j %Y'),
|
||||
('4 53 1998', '%w %u %Y'),
|
||||
('15-01-2001', '%d-%m-%Y %H:%i:%S'),
|
||||
('15-01-20', '%d-%m-%y'),
|
||||
('15-2001-1', '%d-%Y-%c');
|
||||
select date,format,str_to_date(date, format) as str_to_date from t1;
|
||||
date format str_to_date
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
|
||||
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02
|
||||
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
|
||||
10:20:10 %H:%i:%s 0000-00-00 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
|
||||
10:20:10 %T 0000-00-00 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
|
||||
10:20:10AM %r 0000-00-00 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
|
||||
15 September 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
|
||||
15th May 2001 %D %b %Y 2001-05-15 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
|
||||
Sunday 01 2001 %W %v %x 2001-01-07 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00
|
||||
060 2004 %j %Y 2004-02-29 00:00:00
|
||||
4 53 1998 %w %u %Y 1998-12-31 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
|
||||
15-01-20 %d-%m-%y 2020-01-15 00:00:00
|
||||
15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
|
||||
select date,format,concat('',str_to_date(date, format)) as con from t1;
|
||||
date format con
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
|
||||
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02
|
||||
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.123450
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
|
||||
10:20:10 %H:%i:%s 0000-00-00 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
|
||||
10:20:10 %T 0000-00-00 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
|
||||
10:20:10AM %r 0000-00-00 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
|
||||
15 September 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
|
||||
15th May 2001 %D %b %Y 2001-05-15 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
|
||||
Sunday 01 2001 %W %v %x 2001-01-07 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00
|
||||
060 2004 %j %Y 2004-02-29 00:00:00
|
||||
4 53 1998 %w %u %Y 1998-12-31 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
|
||||
15-01-20 %d-%m-%y 2020-01-15 00:00:00
|
||||
15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
|
||||
select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1;
|
||||
date format datetime
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
|
||||
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02 08:11:02
|
||||
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
|
||||
10:20:10 %H:%i:%s 0000-00-00 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
|
||||
10:20:10 %T 0000-00-00 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
|
||||
10:20:10AM %r 0000-00-00 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
|
||||
15 September 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
|
||||
15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
|
||||
15th May 2001 %D %b %Y 2001-05-15 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
|
||||
Sunday 01 2001 %W %v %x 2001-01-07 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00
|
||||
060 2004 %j %Y 2004-02-29 00:00:00
|
||||
4 53 1998 %w %u %Y 1998-12-31 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
|
||||
15-01-20 %d-%m-%y 2020-01-15 00:00:00
|
||||
15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
|
||||
select date,format,DATE(str_to_date(date, format)) as date2 from t1;
|
||||
date format date2
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02
|
||||
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 0003-01-02
|
||||
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02
|
||||
10:20:10 %H:%i:%s 0000-00-00
|
||||
10:20:10 %h:%i:%s.%f 0000-00-00
|
||||
10:20:10 %T 0000-00-00
|
||||
10:20:10AM %h:%i:%s%p 0000-00-00
|
||||
10:20:10AM %r 0000-00-00
|
||||
10:20:10.44AM %h:%i:%s.%f%p 0000-00-00
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15
|
||||
15 September 2001 %d %M %Y 2001-09-15
|
||||
15 SEPTEMB 2001 %d %M %Y 2001-09-15
|
||||
15 MAY 2001 %d %b %Y 2001-05-15
|
||||
15th May 2001 %D %b %Y 2001-05-15
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15
|
||||
Sund 15 MAY 2001 %W %d %b %Y 2001-05-15
|
||||
Tuesday 00 2002 %W %U %Y 2002-01-01
|
||||
Thursday 53 1998 %W %u %Y 1998-12-31
|
||||
Sunday 01 2001 %W %v %x 2001-01-07
|
||||
Tuesday 52 2001 %W %V %X 2002-01-01
|
||||
060 2004 %j %Y 2004-02-29
|
||||
4 53 1998 %w %u %Y 1998-12-31
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15
|
||||
15-01-20 %d-%m-%y 2020-01-15
|
||||
15-2001-1 %d-%Y-%c 2001-01-15
|
||||
select date,format,TIME(str_to_date(date, format)) as time from t1;
|
||||
date format time
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
|
||||
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
|
||||
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
|
||||
10:20:10 %H:%i:%s 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 10:20:10
|
||||
10:20:10 %T 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 10:20:10
|
||||
10:20:10AM %r 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
|
||||
15 September 2001 %d %M %Y 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 00:00:00
|
||||
15 MAY 2001 %d %b %Y 00:00:00
|
||||
15th May 2001 %D %b %Y 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 00:00:00
|
||||
Sunday 01 2001 %W %v %x 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 00:00:00
|
||||
060 2004 %j %Y 00:00:00
|
||||
4 53 1998 %w %u %Y 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
|
||||
15-01-20 %d-%m-%y 00:00:00
|
||||
15-2001-1 %d-%Y-%c 00:00:00
|
||||
select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
|
||||
date format time2
|
||||
2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
|
||||
03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02
|
||||
0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
|
||||
03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
|
||||
2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450
|
||||
2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450
|
||||
2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450
|
||||
2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
|
||||
10:20:10 %H:%i:%s 10:20:10
|
||||
10:20:10 %h:%i:%s.%f 10:20:10
|
||||
10:20:10 %T 10:20:10
|
||||
10:20:10AM %h:%i:%s%p 10:20:10
|
||||
10:20:10AM %r 10:20:10
|
||||
10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000
|
||||
15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
|
||||
15 September 2001 %d %M %Y 00:00:00
|
||||
15 SEPTEMB 2001 %d %M %Y 00:00:00
|
||||
15 MAY 2001 %d %b %Y 00:00:00
|
||||
15th May 2001 %D %b %Y 00:00:00
|
||||
Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
|
||||
Sund 15 MAY 2001 %W %d %b %Y 00:00:00
|
||||
Tuesday 00 2002 %W %U %Y 00:00:00
|
||||
Thursday 53 1998 %W %u %Y 00:00:00
|
||||
Sunday 01 2001 %W %v %x 00:00:00
|
||||
Tuesday 52 2001 %W %V %X 00:00:00
|
||||
060 2004 %j %Y 00:00:00
|
||||
4 53 1998 %w %u %Y 00:00:00
|
||||
15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
|
||||
15-01-20 %d-%m-%y 00:00:00
|
||||
15-2001-1 %d-%Y-%c 00:00:00
|
||||
select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'));
|
||||
concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'))
|
||||
2003-01-02 08:11:02.123456
|
||||
truncate table t1;
|
||||
insert into t1 values
|
||||
('2003-01-02 10:11:12 PM', '%Y-%m-%d %H:%i:%S %p'),
|
||||
('2003-01-02 10:11:12.123456', '%Y-%m-%d %h:%i:%S %p'),
|
||||
('2003-01-02 10:11:12AM', '%Y-%m-%d %h:%i:%S.%f %p'),
|
||||
('2003-01-02 10:11:12AN', '%Y-%m-%d %h:%i:%S%p'),
|
||||
('2003-01-02 10:11:12 PM', '%y-%m-%d %H:%i:%S %p'),
|
||||
('10:20:10AM', '%H:%i:%s%p'),
|
||||
('15 Septembei 2001', '%d %M %Y'),
|
||||
('15 Ju 2001', '%d %M %Y'),
|
||||
('Sund 15 MA', '%W %d %b %Y'),
|
||||
('Thursdai 12 1998', '%W %u %Y'),
|
||||
('Sunday 01 2001', '%W %v %X'),
|
||||
('Tuesday 52 2001', '%W %V %x'),
|
||||
('Tuesday 52 2001', '%W %V %Y'),
|
||||
('Tuesday 52 2001', '%W %u %x'),
|
||||
('7 53 1998', '%w %u %Y'),
|
||||
(NULL, get_format(DATE,'USA'));
|
||||
select date,format,str_to_date(date, format) as str_to_date from t1;
|
||||
date format str_to_date
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
|
||||
2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
|
||||
2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
|
||||
2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
|
||||
2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
|
||||
10:20:10AM %H:%i:%s%p NULL
|
||||
15 Septembei 2001 %d %M %Y NULL
|
||||
15 Ju 2001 %d %M %Y NULL
|
||||
Sund 15 MA %W %d %b %Y NULL
|
||||
Thursdai 12 1998 %W %u %Y NULL
|
||||
Sunday 01 2001 %W %v %X NULL
|
||||
Tuesday 52 2001 %W %V %x NULL
|
||||
Tuesday 52 2001 %W %V %Y NULL
|
||||
Tuesday 52 2001 %W %u %x NULL
|
||||
7 53 1998 %w %u %Y NULL
|
||||
NULL %m.%d.%Y NULL
|
||||
Warnings:
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12.123456' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12AM' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12AN' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '10:20:10AM' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '15 Septembei 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '15 Ju 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Sund 15 MA' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Thursdai 12 1998' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Sunday 01 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '7 53 1998' for function str_to_date
|
||||
select date,format,concat(str_to_date(date, format),'') as con from t1;
|
||||
date format con
|
||||
2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
|
||||
2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
|
||||
2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
|
||||
2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
|
||||
2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
|
||||
10:20:10AM %H:%i:%s%p NULL
|
||||
15 Septembei 2001 %d %M %Y NULL
|
||||
15 Ju 2001 %d %M %Y NULL
|
||||
Sund 15 MA %W %d %b %Y NULL
|
||||
Thursdai 12 1998 %W %u %Y NULL
|
||||
Sunday 01 2001 %W %v %X NULL
|
||||
Tuesday 52 2001 %W %V %x NULL
|
||||
Tuesday 52 2001 %W %V %Y NULL
|
||||
Tuesday 52 2001 %W %u %x NULL
|
||||
7 53 1998 %w %u %Y NULL
|
||||
NULL %m.%d.%Y NULL
|
||||
Warnings:
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12.123456' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12AM' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12AN' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '10:20:10AM' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '15 Septembei 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '15 Ju 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Sund 15 MA' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Thursdai 12 1998' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Sunday 01 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
|
||||
Warning 1411 Incorrect datetime value: '7 53 1998' for function str_to_date
|
||||
truncate table t1;
|
||||
insert into t1 values
|
||||
('10:20:10AM', '%h:%i:%s'),
|
||||
('2003-01-02 10:11:12', '%Y-%m-%d %h:%i:%S'),
|
||||
('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p');
|
||||
select date,format,str_to_date(date, format) as str_to_date from t1;
|
||||
date format str_to_date
|
||||
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
|
||||
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
|
||||
select date,format,concat(str_to_date(date, format),'') as con from t1;
|
||||
date format con
|
||||
10:20:10AM %h:%i:%s 0000-00-00 10:20:10
|
||||
2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
|
||||
03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
|
||||
drop table t1;
|
||||
select get_format(DATE, 'USA') as a;
|
||||
a
|
||||
%m.%d.%Y
|
||||
select get_format(TIME, 'internal') as a;
|
||||
a
|
||||
%H%i%s
|
||||
select get_format(DATETIME, 'eur') as a;
|
||||
a
|
||||
%Y-%m-%d %H.%i.%s
|
||||
select get_format(TIMESTAMP, 'eur') as a;
|
||||
a
|
||||
%Y-%m-%d %H.%i.%s
|
||||
select get_format(DATE, 'TEST') as a;
|
||||
a
|
||||
NULL
|
||||
select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'));
|
||||
str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'))
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1411 Incorrect datetime value: '15-01-2001 12:59:59' for function str_to_date
|
||||
explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001");
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select makedate(1997,1) AS `makedate(1997,1)`,addtime('31.12.97 11.59.59.999999 PM','1 1.1.1.000002') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime('31.12.97 11.59.59.999999 PM','1 1.1.1.000002') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff('01.01.97 11:59:59.000001 PM','31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date('15-01-2001 12:59:59','%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond('1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")`
|
||||
create table t1 (d date);
|
||||
insert into t1 values ('2004-07-14'),('2005-07-14');
|
||||
select date_format(d,"%d") from t1 order by 1;
|
||||
date_format(d,"%d")
|
||||
14
|
||||
14
|
||||
drop table t1;
|
||||
select str_to_date("2003-....01ABCD-02 10:11:12.0012", "%Y-%.%m%@-%d %H:%i:%S.%f") as a;
|
||||
a
|
||||
2003-01-02 10:11:12.001200
|
||||
create table t1 select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
|
||||
str_to_date("10:11:12.0012", "%H:%i:%S.%f") as f2,
|
||||
str_to_date("2003-01-02", "%Y-%m-%d") as f3,
|
||||
str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5;
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
f1 datetime(6) YES NULL
|
||||
f2 time(6) YES NULL
|
||||
f3 date YES NULL
|
||||
f4 date YES NULL
|
||||
f5 time YES NULL
|
||||
select * from t1;
|
||||
f1 f2 f3 f4 f5
|
||||
2003-01-02 10:11:12.001200 10:11:12.001200 2003-01-02 0000-00-02 58:00:00
|
||||
drop table t1;
|
||||
create table t1 select "02 10" as a, "%d %H" as b;
|
||||
select str_to_date(a,b) from t1;
|
||||
str_to_date(a,b)
|
||||
0000-00-02 10:00:00
|
||||
create table t2 select str_to_date(a,b) from t1;
|
||||
describe t2;
|
||||
Field Type Null Key Default Extra
|
||||
str_to_date(a,b) datetime(6) YES NULL
|
||||
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
|
||||
str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2,
|
||||
str_to_date("2003-01-02", "%Y-%m-%d") as f3,
|
||||
str_to_date("02 10:11:12", "%d %H:%i:%S.%f") as f4,
|
||||
str_to_date("02 10:11:12", "%d %H:%i:%S") as f5,
|
||||
str_to_date("02 10", "%d %f") as f6;
|
||||
f1 f2 f3 f4 f5 f6
|
||||
2003-01-02 10:11:12.001200 2003-01-02 10:11:12 2003-01-02 58:11:12.000000 58:11:12 48:00:00.100000
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012'
|
||||
drop table t1, t2;
|
||||
select str_to_date("2003-01-02 10:11:12.0012ABCD", "%Y-%m-%d %H:%i:%S.%f") as f1,
|
||||
addtime("-01:01:01.01 GGG", "-23:59:59.1") as f2,
|
||||
microsecond("1997-12-31 23:59:59.01XXXX") as f3;
|
||||
f1 f2 f3
|
||||
2003-01-02 10:11:12.001200 -25:01:00.110000 10000
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012ABCD'
|
||||
Warning 1292 Truncated incorrect time value: '-01:01:01.01 GGG'
|
||||
Warning 1292 Truncated incorrect time value: '1997-12-31 23:59:59.01XXXX'
|
||||
select str_to_date("2003-04-05 g", "%Y-%m-%d") as f1,
|
||||
str_to_date("2003-04-05 10:11:12.101010234567", "%Y-%m-%d %H:%i:%S.%f") as f2;
|
||||
f1 f2
|
||||
2003-04-05 2003-04-05 10:11:12.101010
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect date value: '2003-04-05 g'
|
||||
Warning 1292 Truncated incorrect datetime value: '2003-04-05 10:11:12.101010234567'
|
||||
set names latin1;
|
||||
select date_format('2004-01-01','%W (%a), %e %M (%b) %Y');
|
||||
date_format('2004-01-01','%W (%a), %e %M (%b) %Y')
|
||||
Thursday (Thu), 1 January (Jan) 2004
|
||||
set lc_time_names=ru_RU;
|
||||
set names koi8r;
|
||||
select date_format('2004-01-01','%W (%a), %e %M (%b) %Y');
|
||||
date_format('2004-01-01','%W (%a), %e %M (%b) %Y')
|
||||
þÅÔ×ÅÒÇ (þÔ×), 1 ñÎ×ÁÒÑ (ñÎ×) 2004
|
||||
set lc_time_names=de_DE;
|
||||
set names latin1;
|
||||
select date_format('2004-01-01','%W (%a), %e %M (%b) %Y');
|
||||
date_format('2004-01-01','%W (%a), %e %M (%b) %Y')
|
||||
Donnerstag (Do), 1 Januar (Jan) 2004
|
||||
set names latin1;
|
||||
set lc_time_names=en_US;
|
||||
create table t1 (f1 datetime);
|
||||
insert into t1 (f1) values ("2005-01-01");
|
||||
insert into t1 (f1) values ("2005-02-01");
|
||||
select date_format(f1, "%m") as d1, date_format(f1, "%M") as d2 from t1 order by date_format(f1, "%M");
|
||||
d1 d2
|
||||
02 February
|
||||
01 January
|
||||
drop table t1;
|
||||
select str_to_date( 1, NULL );
|
||||
str_to_date( 1, NULL )
|
||||
NULL
|
||||
select str_to_date( NULL, 1 );
|
||||
str_to_date( NULL, 1 )
|
||||
NULL
|
||||
select str_to_date( 1, IF(1=1,NULL,NULL) );
|
||||
str_to_date( 1, IF(1=1,NULL,NULL) )
|
||||
NULL
|
||||
SELECT TIME_FORMAT("24:00:00", '%r');
|
||||
TIME_FORMAT("24:00:00", '%r')
|
||||
12:00:00 AM
|
||||
SELECT TIME_FORMAT("00:00:00", '%r');
|
||||
TIME_FORMAT("00:00:00", '%r')
|
||||
12:00:00 AM
|
||||
SELECT TIME_FORMAT("12:00:00", '%r');
|
||||
TIME_FORMAT("12:00:00", '%r')
|
||||
12:00:00 PM
|
||||
SELECT TIME_FORMAT("15:00:00", '%r');
|
||||
TIME_FORMAT("15:00:00", '%r')
|
||||
03:00:00 PM
|
||||
SELECT TIME_FORMAT("01:00:00", '%r');
|
||||
TIME_FORMAT("01:00:00", '%r')
|
||||
01:00:00 AM
|
||||
SELECT TIME_FORMAT("25:00:00", '%r');
|
||||
TIME_FORMAT("25:00:00", '%r')
|
||||
01:00:00 AM
|
||||
SELECT TIME_FORMAT("00:00:00", '%l %p');
|
||||
TIME_FORMAT("00:00:00", '%l %p')
|
||||
12 AM
|
||||
SELECT TIME_FORMAT("01:00:00", '%l %p');
|
||||
TIME_FORMAT("01:00:00", '%l %p')
|
||||
1 AM
|
||||
SELECT TIME_FORMAT("12:00:00", '%l %p');
|
||||
TIME_FORMAT("12:00:00", '%l %p')
|
||||
12 PM
|
||||
SELECT TIME_FORMAT("23:00:00", '%l %p');
|
||||
TIME_FORMAT("23:00:00", '%l %p')
|
||||
11 PM
|
||||
SELECT TIME_FORMAT("24:00:00", '%l %p');
|
||||
TIME_FORMAT("24:00:00", '%l %p')
|
||||
12 AM
|
||||
SELECT TIME_FORMAT("25:00:00", '%l %p');
|
||||
TIME_FORMAT("25:00:00", '%l %p')
|
||||
1 AM
|
||||
SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896);
|
||||
DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '%Y-%m-%d %H:%i:%s'
|
||||
select str_to_date('04 /30/2004', '%m /%d/%Y');
|
||||
str_to_date('04 /30/2004', '%m /%d/%Y')
|
||||
2004-04-30
|
||||
select str_to_date('04/30 /2004', '%m /%d /%Y');
|
||||
str_to_date('04/30 /2004', '%m /%d /%Y')
|
||||
2004-04-30
|
||||
select str_to_date('04/30/2004 ', '%m/%d/%Y ');
|
||||
str_to_date('04/30/2004 ', '%m/%d/%Y ')
|
||||
2004-04-30
|
||||
"End of 4.1 tests"
|
@ -1,197 +0,0 @@
|
||||
drop table if exists t1,t2,t3,t4,t5,t6;
|
||||
drop database if exists mysqltest;
|
||||
CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
c varchar(4) binary NOT NULL DEFAULT '0000',
|
||||
d tinyblob NULL,
|
||||
e tinyblob NULL,
|
||||
f tinyblob NULL,
|
||||
g tinyblob NULL,
|
||||
h tinyblob NULL,
|
||||
i tinyblob NULL,
|
||||
j tinyblob NULL,
|
||||
k tinyblob NULL,
|
||||
l tinyblob NULL,
|
||||
m tinyblob NULL,
|
||||
n tinyblob NULL,
|
||||
o tinyblob NULL,
|
||||
p tinyblob NULL,
|
||||
q varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
r varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
s tinyblob NULL,
|
||||
t varchar(4) binary NOT NULL DEFAULT ' ',
|
||||
u varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
v varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
w varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
x tinyblob NULL,
|
||||
y varchar(5) binary NOT NULL DEFAULT ' ',
|
||||
z varchar(20) binary NOT NULL DEFAULT ' ',
|
||||
a1 varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b1 tinyblob NULL)
|
||||
ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
|
||||
INSERT into t1 (b) values ('1');
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
SELECT * from t1;
|
||||
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
|
||||
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
c varchar(4) binary NOT NULL DEFAULT '0000',
|
||||
d tinyblob NULL,
|
||||
e tinyblob NULL,
|
||||
f tinyblob NULL,
|
||||
g tinyblob NULL,
|
||||
h tinyblob NULL,
|
||||
i tinyblob NULL,
|
||||
j tinyblob NULL,
|
||||
k tinyblob NULL,
|
||||
l tinyblob NULL,
|
||||
m tinyblob NULL,
|
||||
n tinyblob NULL,
|
||||
o tinyblob NULL,
|
||||
p tinyblob NULL,
|
||||
q varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
r varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
s tinyblob NULL,
|
||||
t varchar(4) binary NOT NULL DEFAULT ' ',
|
||||
u varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
v varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
w varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
x tinyblob NULL,
|
||||
y varchar(5) binary NOT NULL DEFAULT ' ',
|
||||
z varchar(20) binary NOT NULL DEFAULT ' ',
|
||||
a1 varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b1 tinyblob NULL)
|
||||
ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`b` varchar(1) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`c` varchar(4) COLLATE latin1_bin NOT NULL DEFAULT '0000',
|
||||
`d` tinyblob,
|
||||
`e` tinyblob,
|
||||
`f` tinyblob,
|
||||
`g` tinyblob,
|
||||
`h` tinyblob,
|
||||
`i` tinyblob,
|
||||
`j` tinyblob,
|
||||
`k` tinyblob,
|
||||
`l` tinyblob,
|
||||
`m` tinyblob,
|
||||
`n` tinyblob,
|
||||
`o` tinyblob,
|
||||
`p` tinyblob,
|
||||
`q` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`r` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`s` tinyblob,
|
||||
`t` varchar(4) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`u` varchar(1) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`v` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`w` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`x` tinyblob,
|
||||
`y` varchar(5) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`z` varchar(20) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`a1` varchar(30) COLLATE latin1_bin NOT NULL DEFAULT ' ',
|
||||
`b1` tinyblob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin
|
||||
INSERT into t2 (b) values ('1');
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
SELECT * from t2;
|
||||
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
|
||||
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table bug20691 (i int, d datetime NOT NULL, dn datetime not null default '0000-00-00 00:00:00');
|
||||
insert into bug20691 values (1, DEFAULT, DEFAULT), (1, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (1, DEFAULT, DEFAULT);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
insert into bug20691 (i) values (2);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
desc bug20691;
|
||||
Field Type Null Key Default Extra
|
||||
i int(11) YES NULL
|
||||
d datetime NO NULL
|
||||
dn datetime NO 0000-00-00 00:00:00
|
||||
insert into bug20691 values (3, DEFAULT, DEFAULT), (3, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (3, DEFAULT, DEFAULT);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
insert into bug20691 (i) values (4);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
insert into bug20691 values (5, DEFAULT, DEFAULT), (5, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (5, DEFAULT, DEFAULT);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
SET sql_mode = 'ALLOW_INVALID_DATES';
|
||||
insert into bug20691 values (6, DEFAULT, DEFAULT), (6, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (6, DEFAULT, DEFAULT);
|
||||
Warnings:
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
SET sql_mode = 'STRICT_ALL_TABLES';
|
||||
insert into bug20691 values (7, DEFAULT, DEFAULT), (7, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (7, DEFAULT, DEFAULT);
|
||||
ERROR HY000: Field 'd' doesn't have a default value
|
||||
select * from bug20691 order by i asc;
|
||||
i d dn
|
||||
1 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
1 1975-07-10 07:10:03 1978-01-13 14:08:51
|
||||
1 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
2 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
3 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
3 1975-07-10 07:10:03 1978-01-13 14:08:51
|
||||
3 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
4 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
5 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
5 1975-07-10 07:10:03 1978-01-13 14:08:51
|
||||
5 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
6 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
6 1975-07-10 07:10:03 1978-01-13 14:08:51
|
||||
6 0000-00-00 00:00:00 0000-00-00 00:00:00
|
||||
drop table bug20691;
|
||||
SET sql_mode = '';
|
||||
create table bug20691 (
|
||||
a set('one', 'two', 'three') not null,
|
||||
b enum('small', 'medium', 'large', 'enormous', 'ellisonego') not null,
|
||||
c time not null,
|
||||
d date not null,
|
||||
e int not null,
|
||||
f long not null,
|
||||
g blob not null,
|
||||
h datetime not null,
|
||||
i decimal not null,
|
||||
x int);
|
||||
insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 1);
|
||||
insert into bug20691 (x) values (2);
|
||||
Warnings:
|
||||
Warning 1364 Field 'a' doesn't have a default value
|
||||
Warning 1364 Field 'c' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'e' doesn't have a default value
|
||||
Warning 1364 Field 'f' doesn't have a default value
|
||||
Warning 1364 Field 'g' doesn't have a default value
|
||||
Warning 1364 Field 'h' doesn't have a default value
|
||||
Warning 1364 Field 'i' doesn't have a default value
|
||||
insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 3);
|
||||
insert into bug20691 values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, 4);
|
||||
Warnings:
|
||||
Warning 1364 Field 'a' doesn't have a default value
|
||||
Warning 1364 Field 'c' doesn't have a default value
|
||||
Warning 1364 Field 'd' doesn't have a default value
|
||||
Warning 1364 Field 'e' doesn't have a default value
|
||||
Warning 1364 Field 'f' doesn't have a default value
|
||||
Warning 1364 Field 'g' doesn't have a default value
|
||||
Warning 1364 Field 'h' doesn't have a default value
|
||||
Warning 1364 Field 'i' doesn't have a default value
|
||||
select * from bug20691 order by x asc;
|
||||
a b c d e f g h i x
|
||||
two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 1
|
||||
small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 2
|
||||
two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 3
|
||||
small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 4
|
||||
drop table bug20691;
|
||||
End of 5.0 tests.
|
@ -1,208 +0,0 @@
|
||||
drop table if exists t1,t2,t3,t11,t12;
|
||||
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
|
||||
INSERT INTO t1 VALUES (1,1);
|
||||
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
DELETE from t1 where a=1 limit 1;
|
||||
DELETE LOW_PRIORITY from t1 where a=1;
|
||||
INSERT INTO t1 VALUES (1,1);
|
||||
DELETE from t1;
|
||||
LOCK TABLE t1 write;
|
||||
INSERT INTO t1 VALUES (1,2);
|
||||
DELETE from t1;
|
||||
UNLOCK TABLES;
|
||||
INSERT INTO t1 VALUES (1,2);
|
||||
SET AUTOCOMMIT=0;
|
||||
DELETE from t1;
|
||||
SET AUTOCOMMIT=1;
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a bigint not null,
|
||||
b bigint not null default 0,
|
||||
c bigint not null default 0,
|
||||
d bigint not null default 0,
|
||||
e bigint not null default 0,
|
||||
f bigint not null default 0,
|
||||
g bigint not null default 0,
|
||||
h bigint not null default 0,
|
||||
i bigint not null default 0,
|
||||
j bigint not null default 0,
|
||||
primary key (a,b,c,d,e,f,g,h,i,j));
|
||||
insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23);
|
||||
delete from t1 where a=26;
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a bigint not null,
|
||||
b bigint not null default 0,
|
||||
c bigint not null default 0,
|
||||
d bigint not null default 0,
|
||||
e bigint not null default 0,
|
||||
f bigint not null default 0,
|
||||
g bigint not null default 0,
|
||||
h bigint not null default 0,
|
||||
i bigint not null default 0,
|
||||
j bigint not null default 0,
|
||||
primary key (a,b,c,d,e,f,g,h,i,j));
|
||||
insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
|
||||
delete from t1 where a=27;
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`i` int(10) NOT NULL default '0',
|
||||
`i2` int(10) NOT NULL default '0',
|
||||
PRIMARY KEY (`i`)
|
||||
);
|
||||
DELETE FROM t1 USING t1 WHERE post='1';
|
||||
ERROR 42S22: Unknown column 'post' in 'where clause'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
bool char(0) default NULL,
|
||||
not_null varchar(20) binary NOT NULL default '',
|
||||
misc integer not null,
|
||||
PRIMARY KEY (not_null)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7);
|
||||
select * from t1 where misc > 5 and bool is null;
|
||||
bool not_null misc
|
||||
NULL c 6
|
||||
NULL d 7
|
||||
delete from t1 where misc > 5 and bool is null;
|
||||
select * from t1 where misc > 5 and bool is null;
|
||||
bool not_null misc
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
2
|
||||
delete from t1 where 1 > 2;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
2
|
||||
delete from t1 where 3 > 2;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
0
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment primary key, b char(32));
|
||||
insert into t1 (b) values ('apple'), ('apple');
|
||||
select * from t1;
|
||||
a b
|
||||
1 apple
|
||||
2 apple
|
||||
delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
|
||||
select * from t1;
|
||||
a b
|
||||
1 apple
|
||||
drop table t1;
|
||||
create table t11 (a int NOT NULL, b int, primary key (a));
|
||||
create table t12 (a int NOT NULL, b int, primary key (a));
|
||||
create table t2 (a int NOT NULL, b int, primary key (a));
|
||||
insert into t11 values (0, 10),(1, 11),(2, 12);
|
||||
insert into t12 values (33, 10),(0, 11),(2, 12);
|
||||
insert into t2 values (1, 21),(2, 12),(3, 23);
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
0 11
|
||||
2 12
|
||||
select * from t2;
|
||||
a b
|
||||
1 21
|
||||
2 12
|
||||
3 23
|
||||
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
0 11
|
||||
2 12
|
||||
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
0 11
|
||||
2 12
|
||||
insert into t11 values (2, 12);
|
||||
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
|
||||
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
drop table t11, t12, t2;
|
||||
create table t1 (a int, b int, unique key (a), key (b));
|
||||
insert into t1 values (3, 3), (7, 7);
|
||||
delete t1 from t1 where a = 3;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select * from t1;
|
||||
a b
|
||||
7 7
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a int PRIMARY KEY );
|
||||
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
|
||||
INSERT INTO t1 VALUES (0),(1),(2);
|
||||
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1;
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
0
|
||||
2
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int);
|
||||
delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
|
||||
delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int not null,b int not null);
|
||||
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
|
||||
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
|
||||
insert into t1 values (1,1),(2,1),(1,3);
|
||||
insert into t2 values (1,1),(2,2),(3,3);
|
||||
insert into t3 values (1,1),(2,1),(1,3);
|
||||
select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
|
||||
a b a b a b
|
||||
1 1 1 1 1 1
|
||||
2 1 2 2 2 1
|
||||
1 3 1 1 1 3
|
||||
explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b,test.t1.b 1 Using index
|
||||
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
|
||||
select * from t3;
|
||||
a b
|
||||
drop table t1,t2,t3;
|
||||
create table t1(a date not null);
|
||||
insert into t1 values (0);
|
||||
select * from t1 where a is null;
|
||||
a
|
||||
0000-00-00
|
||||
delete from t1 where a is null;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
0
|
||||
drop table t1;
|
@ -1,393 +0,0 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
set @save_derived_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='derived_merge=off,derived_with_keys=off';
|
||||
select * from (select 2 from DUAL) b;
|
||||
2
|
||||
2
|
||||
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
CREATE TABLE t1 (a int not null, b char (10) not null);
|
||||
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
|
||||
CREATE TABLE t2 (a int not null, b char (10) not null);
|
||||
insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
|
||||
select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y;
|
||||
a y
|
||||
3 3
|
||||
3 3
|
||||
select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a;
|
||||
a a
|
||||
3 3
|
||||
3 3
|
||||
CREATE TABLE t3 (a int not null, b char (10) not null);
|
||||
insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
|
||||
select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y;
|
||||
a y
|
||||
3 3
|
||||
3 3
|
||||
SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'having clause'
|
||||
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
|
||||
ERROR 23000: Column 'a' in having clause is ambiguous
|
||||
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
|
||||
a a
|
||||
1 2
|
||||
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
|
||||
a a
|
||||
SELECT 1 FROM (SELECT 1) a WHERE a=2;
|
||||
ERROR 42S22: Unknown column 'a' in 'where clause'
|
||||
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
|
||||
ERROR 42S22: Unknown column 'a' in 'having clause'
|
||||
select * from t1 as x1, (select * from t1) as x2;
|
||||
a b a b
|
||||
1 a 1 a
|
||||
2 b 1 a
|
||||
3 c 1 a
|
||||
3 c 1 a
|
||||
1 a 2 b
|
||||
2 b 2 b
|
||||
3 c 2 b
|
||||
3 c 2 b
|
||||
1 a 3 c
|
||||
2 b 3 c
|
||||
3 c 3 c
|
||||
3 c 3 c
|
||||
1 a 3 c
|
||||
2 b 3 c
|
||||
3 c 3 c
|
||||
3 c 3 c
|
||||
explain select * from t1 as x1, (select * from t1) as x2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY x1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4
|
||||
drop table if exists t2,t3;
|
||||
select * from (select 1) as a;
|
||||
1
|
||||
1
|
||||
select a from (select 1 as a) as b;
|
||||
a
|
||||
1
|
||||
select 1 from (select 1) as a;
|
||||
1
|
||||
1
|
||||
select * from (select * from t1 union select * from t1) a;
|
||||
a b
|
||||
1 a
|
||||
2 b
|
||||
3 c
|
||||
select * from (select * from t1 union all select * from t1) a;
|
||||
a b
|
||||
1 a
|
||||
2 b
|
||||
3 c
|
||||
3 c
|
||||
1 a
|
||||
2 b
|
||||
3 c
|
||||
3 c
|
||||
select * from (select * from t1 union all select * from t1 limit 2) a;
|
||||
a b
|
||||
1 a
|
||||
2 b
|
||||
explain select * from (select * from t1 union select * from t1) a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 8
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4
|
||||
3 UNION t1 ALL NULL NULL NULL NULL 4
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
explain select * from (select * from t1 union all select * from t1) a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 8
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4
|
||||
3 UNION t1 ALL NULL NULL NULL NULL 4
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
CREATE TABLE t2 (a int not null);
|
||||
insert into t2 values(1);
|
||||
select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a;
|
||||
a b
|
||||
1 a
|
||||
select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a;
|
||||
a b
|
||||
1 a
|
||||
2 b
|
||||
3 c
|
||||
explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
|
||||
2 DERIVED t2 ALL NULL NULL NULL NULL 1
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t1, t2;
|
||||
create table t1(a int not null, t char(8), index(a));
|
||||
SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
|
||||
a t
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 9
|
||||
10 10
|
||||
11 11
|
||||
12 12
|
||||
13 13
|
||||
14 14
|
||||
15 15
|
||||
16 16
|
||||
17 17
|
||||
18 18
|
||||
19 19
|
||||
20 20
|
||||
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY tt1 index NULL a 4 NULL 10000 Using index
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 10000 Using join buffer (flat, BNL join)
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 10000
|
||||
drop table t1;
|
||||
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
|
||||
(SELECT * FROM (SELECT 1 as a) as a )
|
||||
1
|
||||
select * from (select 1 as a) b left join (select 2 as a) c using(a);
|
||||
a
|
||||
1
|
||||
SELECT * FROM (SELECT 1 UNION SELECT a) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
|
||||
ERROR 42S22: Unknown column 'a' in 'field list'
|
||||
select 1 from (select 2) a order by 0;
|
||||
ERROR 42S22: Unknown column '0' in 'order clause'
|
||||
create table t1 (id int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
describe select * from (select * from t1 group by id) bar;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
|
||||
drop table t1;
|
||||
create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
|
||||
create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
|
||||
insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
|
||||
insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
|
||||
SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
pla_id mat_id
|
||||
100 1
|
||||
101 1
|
||||
102 1
|
||||
103 2
|
||||
104 2
|
||||
105 3
|
||||
SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
pla_id test
|
||||
100 1
|
||||
101 1
|
||||
102 1
|
||||
103 2
|
||||
104 2
|
||||
105 3
|
||||
explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where; Using join buffer (flat, BNL join)
|
||||
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
|
||||
explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where; Using join buffer (flat, BNL join)
|
||||
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
|
||||
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
|
||||
drop table t1,t2;
|
||||
SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1;
|
||||
x
|
||||
1
|
||||
create user mysqltest_1;
|
||||
create table t1 select 1 as a;
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
set optimizer_switch='derived_merge=off,derived_with_keys=off';
|
||||
select 2 as a from (select * from t1) b;
|
||||
ERROR 3D000: No database selected
|
||||
use test;
|
||||
select 2 as a from (select * from t1) b;
|
||||
a
|
||||
2
|
||||
drop table t1;
|
||||
select mail_id, if(folder.f_description!='', folder.f_description, folder.f_name) as folder_name, date, address_id, phrase, address, subject from folder, (select mail.mail_id as mail_id, date_format(mail.h_date, '%b %e, %Y %h:%i') as date, mail.folder_id, sender.address_id as address_id, sender.phrase as phrase, sender.address as address, mail.h_subject as subject from mail left join mxa as mxa_sender on mail.mail_id=mxa_sender.mail_id and mxa_sender.type='from' left join address as sender on mxa_sender.address_id=sender.address_id mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_recipient.mail_id and mxa_recipient.address_id=recipient.address_id and mxa_recipient.type='to' and match(sender.phrase, sender.address, sender.comment) against ('jeremy' in boolean mode) and match(recipient.phrase, recipient.address, recipient.comment) against ('monty' in boolean mode) order by mail.h_date desc limit 0, 25 ) as query where query.folder_id=folder.folder_id;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_r' at line 1
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
update (select * from t1) as t1 set a = 5;
|
||||
ERROR HY000: The target table t1 of the UPDATE is not updatable
|
||||
delete from (select * from t1);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(select * from t1)' at line 1
|
||||
insert into (select * from t1) values (5);
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(select * from t1) values (5)' at line 1
|
||||
drop table t1;
|
||||
create table t1 (E1 INTEGER UNSIGNED NOT NULL, E2 INTEGER UNSIGNED NOT NULL, E3 INTEGER UNSIGNED NOT NULL, PRIMARY KEY(E1)
|
||||
);
|
||||
insert into t1 VALUES(1,1,1), (2,2,1);
|
||||
select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
|
||||
count(*)
|
||||
2
|
||||
explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 THEMAX.E2 1 Using where
|
||||
2 DERIVED A ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
|
||||
a a
|
||||
1 1
|
||||
2 1
|
||||
1 2
|
||||
2 2
|
||||
explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <derived4> ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
4 DERIVED t1 ALL NULL NULL NULL NULL 2
|
||||
5 UNION t1 ALL NULL NULL NULL NULL 2
|
||||
NULL UNION RESULT <union4,5> ALL NULL NULL NULL NULL NULL
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 2
|
||||
3 UNION t1 ALL NULL NULL NULL NULL 2
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
drop table t1;
|
||||
CREATE TABLE `t1` (
|
||||
`N` int(11) unsigned NOT NULL default '0',
|
||||
`M` tinyint(1) default '0'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0);
|
||||
UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2;
|
||||
select * from t1;
|
||||
N M
|
||||
1 2
|
||||
1 2
|
||||
1 2
|
||||
2 2
|
||||
2 2
|
||||
3 0
|
||||
UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2, P2.N = 2;
|
||||
ERROR HY000: The target table P2 of the UPDATE is not updatable
|
||||
UPDATE `t1` AS P1 INNER JOIN (SELECT aaaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2;
|
||||
ERROR 42S22: Unknown column 'aaaa' in 'field list'
|
||||
delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
|
||||
select * from t1;
|
||||
N M
|
||||
3 0
|
||||
delete P1.*,p2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS p2 ON P1.N = p2.N;
|
||||
ERROR HY000: The target table p2 of the DELETE is not updatable
|
||||
delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
|
||||
ERROR 42S22: Unknown column 'aaa' in 'field list'
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
OBJECTID int(11) NOT NULL default '0',
|
||||
SORTORDER int(11) NOT NULL auto_increment,
|
||||
KEY t1_SortIndex (SORTORDER),
|
||||
KEY t1_IdIndex (OBJECTID)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
CREATE TABLE t2 (
|
||||
ID int(11) default NULL,
|
||||
PARID int(11) default NULL,
|
||||
UNIQUE KEY t2_ID_IDX (ID),
|
||||
KEY t2_PARID_IDX (PARID)
|
||||
) engine=MyISAM DEFAULT CHARSET=latin1;
|
||||
INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2);
|
||||
CREATE TABLE t3 (
|
||||
ID int(11) default NULL,
|
||||
DATA decimal(10,2) default NULL,
|
||||
UNIQUE KEY t3_ID_IDX (ID)
|
||||
) engine=MyISAM DEFAULT CHARSET=latin1;
|
||||
INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75);
|
||||
select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP;
|
||||
497 ID NULL
|
||||
drop table t1, t2, t3;
|
||||
CREATE TABLE t1 (name char(1) default NULL, val int(5) default NULL);
|
||||
INSERT INTO t1 VALUES ('a',1), ('a',2), ('a',2), ('a',2), ('a',3), ('a',6), ('a',7), ('a',11), ('a',11), ('a',12), ('a',13), ('a',13), ('a',20), ('b',2), ('b',3), ('b',4), ('b',5);
|
||||
SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name;
|
||||
name median
|
||||
a 7.0000
|
||||
b 3.5000
|
||||
explain SELECT s.name, AVG(s.val) AS median FROM (SELECT x.name, x.val FROM t1 x, t1 y WHERE x.name=y.name GROUP BY x.name, x.val HAVING SUM(y.val <= x.val) >= COUNT(*)/2 AND SUM(y.val >= x.val) >= COUNT(*)/2) AS s GROUP BY s.name;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 289 Using temporary; Using filesort
|
||||
2 DERIVED x ALL NULL NULL NULL NULL 17 Using temporary; Using filesort
|
||||
2 DERIVED y ALL NULL NULL NULL NULL 17 Using where; Using join buffer (flat, BNL join)
|
||||
drop table t1;
|
||||
create table t2 (a int, b int, primary key (a));
|
||||
insert into t2 values (1,7),(2,7);
|
||||
explain select a from t2 where a>1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
|
||||
explain select a from (select a from t2 where a>1) tt;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
|
||||
drop table t2;
|
||||
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
|
||||
insert into t1 values (128, 'rozn', 2, curdate(), 10),
|
||||
(128, 'rozn', 1, curdate(), 10);
|
||||
SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices;
|
||||
min max avg
|
||||
10.00 10.00 10
|
||||
DROP TABLE t1;
|
||||
create table t1 (a integer, b integer);
|
||||
insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1);
|
||||
select distinct sum(b) from t1 group by a;
|
||||
sum(b)
|
||||
4
|
||||
select distinct sum(b) from (select a,b from t1) y group by a;
|
||||
sum(b)
|
||||
4
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a char(10), b char(10));
|
||||
INSERT INTO t1 VALUES ('root','localhost'), ('root','%');
|
||||
SELECT * FROM (SELECT (SELECT a.a FROM t1 AS a WHERE a.a = b.a) FROM t1 AS b) AS c;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
DROP TABLE t1;
|
||||
create table t1(a int);
|
||||
create table t2(a int);
|
||||
create table t3(a int);
|
||||
insert into t1 values(1),(1);
|
||||
insert into t2 values(2),(2);
|
||||
insert into t3 values(3),(3);
|
||||
select * from t1 union distinct select * from t2 union all select * from t3;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
3
|
||||
select * from (select * from t1 union distinct select * from t2 union all select * from t3) X;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
3
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
select * from (select * from t1,t2) foo;
|
||||
ERROR 42S21: Duplicate column name 'a'
|
||||
drop table t1,t2;
|
||||
create table t1 (ID int unsigned not null auto_increment,
|
||||
DATA varchar(5) not null, primary key (ID));
|
||||
create table t2 (ID int unsigned not null auto_increment,
|
||||
DATA varchar(5) not null, FID int unsigned not null,
|
||||
primary key (ID));
|
||||
select A.* from (t1 inner join (select * from t2) as A on t1.ID = A.FID);
|
||||
ID DATA FID
|
||||
select t2.* from ((select * from t1) as A inner join t2 on A.ID = t2.FID);
|
||||
ID DATA FID
|
||||
select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID;
|
||||
ID DATA FID
|
||||
drop table t1, t2;
|
||||
drop user mysqltest_1;
|
||||
set optimizer_switch=@save_derived_optimizer_switch;
|
@ -1,9 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (n int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
select * from t1;
|
||||
n
|
||||
1
|
||||
2
|
||||
3
|
||||
drop table t1;
|
@ -1,649 +0,0 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
CREATE TABLE t1 (id int,facility char(20));
|
||||
CREATE TABLE t2 (facility char(20));
|
||||
INSERT INTO t1 VALUES (NULL,NULL);
|
||||
INSERT INTO t1 VALUES (-1,'');
|
||||
INSERT INTO t1 VALUES (0,'');
|
||||
INSERT INTO t1 VALUES (1,'/L');
|
||||
INSERT INTO t1 VALUES (2,'A01');
|
||||
INSERT INTO t1 VALUES (3,'ANC');
|
||||
INSERT INTO t1 VALUES (4,'F01');
|
||||
INSERT INTO t1 VALUES (5,'FBX');
|
||||
INSERT INTO t1 VALUES (6,'MT');
|
||||
INSERT INTO t1 VALUES (7,'P');
|
||||
INSERT INTO t1 VALUES (8,'RV');
|
||||
INSERT INTO t1 VALUES (9,'SRV');
|
||||
INSERT INTO t1 VALUES (10,'VMT');
|
||||
INSERT INTO t2 SELECT DISTINCT FACILITY FROM t1;
|
||||
select id from t1 group by id;
|
||||
id
|
||||
NULL
|
||||
-1
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
select * from t1 order by id;
|
||||
id facility
|
||||
NULL NULL
|
||||
-1
|
||||
0
|
||||
1 /L
|
||||
2 A01
|
||||
3 ANC
|
||||
4 F01
|
||||
5 FBX
|
||||
6 MT
|
||||
7 P
|
||||
8 RV
|
||||
9 SRV
|
||||
10 VMT
|
||||
select id-5,facility from t1 order by "id-5";
|
||||
id-5 facility
|
||||
NULL NULL
|
||||
-6
|
||||
-5
|
||||
-4 /L
|
||||
-3 A01
|
||||
-2 ANC
|
||||
-1 F01
|
||||
0 FBX
|
||||
1 MT
|
||||
2 P
|
||||
3 RV
|
||||
4 SRV
|
||||
5 VMT
|
||||
select id,concat(facility) from t1 group by id ;
|
||||
id concat(facility)
|
||||
NULL NULL
|
||||
-1
|
||||
0
|
||||
1 /L
|
||||
2 A01
|
||||
3 ANC
|
||||
4 F01
|
||||
5 FBX
|
||||
6 MT
|
||||
7 P
|
||||
8 RV
|
||||
9 SRV
|
||||
10 VMT
|
||||
select id+0 as a,max(id),concat(facility) as b from t1 group by a order by b desc,a;
|
||||
a max(id) b
|
||||
10 10 VMT
|
||||
9 9 SRV
|
||||
8 8 RV
|
||||
7 7 P
|
||||
6 6 MT
|
||||
5 5 FBX
|
||||
4 4 F01
|
||||
3 3 ANC
|
||||
2 2 A01
|
||||
1 1 /L
|
||||
-1 -1
|
||||
0 0
|
||||
NULL NULL NULL
|
||||
select id >= 0 and id <= 5 as grp,count(*) from t1 group by grp;
|
||||
grp count(*)
|
||||
NULL 1
|
||||
0 6
|
||||
1 6
|
||||
SELECT DISTINCT FACILITY FROM t1;
|
||||
FACILITY
|
||||
NULL
|
||||
|
||||
/L
|
||||
A01
|
||||
ANC
|
||||
F01
|
||||
FBX
|
||||
MT
|
||||
P
|
||||
RV
|
||||
SRV
|
||||
VMT
|
||||
SELECT FACILITY FROM t2;
|
||||
FACILITY
|
||||
NULL
|
||||
|
||||
/L
|
||||
A01
|
||||
ANC
|
||||
F01
|
||||
FBX
|
||||
MT
|
||||
P
|
||||
RV
|
||||
SRV
|
||||
VMT
|
||||
SELECT count(*) from t1,t2 where t1.facility=t2.facility;
|
||||
count(*)
|
||||
12
|
||||
select count(facility) from t1;
|
||||
count(facility)
|
||||
12
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
13
|
||||
select count(*) from t1 where facility IS NULL;
|
||||
count(*)
|
||||
1
|
||||
select count(*) from t1 where facility = NULL;
|
||||
count(*)
|
||||
0
|
||||
select count(*) from t1 where facility IS NOT NULL;
|
||||
count(*)
|
||||
12
|
||||
select count(*) from t1 where id IS NULL;
|
||||
count(*)
|
||||
1
|
||||
select count(*) from t1 where id IS NOT NULL;
|
||||
count(*)
|
||||
12
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (UserId int(11) DEFAULT '0' NOT NULL);
|
||||
INSERT INTO t1 VALUES (20);
|
||||
INSERT INTO t1 VALUES (27);
|
||||
SELECT UserId FROM t1 WHERE Userid=22;
|
||||
UserId
|
||||
SELECT UserId FROM t1 WHERE UserId=22 group by Userid;
|
||||
UserId
|
||||
SELECT DISTINCT UserId FROM t1 WHERE UserId=22 group by Userid;
|
||||
UserId
|
||||
SELECT DISTINCT UserId FROM t1 WHERE UserId=22;
|
||||
UserId
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int(10) unsigned not null primary key,b int(10) unsigned);
|
||||
INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1);
|
||||
CREATE TABLE t2 (a int(10) unsigned not null, key (A));
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
CREATE TABLE t3 (a int(10) unsigned, key(A), b text);
|
||||
INSERT INTO t3 VALUES (1,'1'),(2,'2');
|
||||
SELECT DISTINCT t3.b FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
|
||||
b
|
||||
1
|
||||
INSERT INTO t2 values (1),(2),(3);
|
||||
INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2');
|
||||
explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using temporary
|
||||
1 SIMPLE t2 ref a a 4 test.t1.a 1 Using index
|
||||
1 SIMPLE t3 ref a a 5 test.t1.b 1 Using index
|
||||
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
|
||||
a
|
||||
1
|
||||
create temporary table t4 select * from t3;
|
||||
insert into t3 select * from t4;
|
||||
insert into t4 select * from t3;
|
||||
insert into t3 select * from t4;
|
||||
insert into t4 select * from t3;
|
||||
insert into t3 select * from t4;
|
||||
insert into t4 select * from t3;
|
||||
insert into t3 select * from t4;
|
||||
explain select distinct t1.a from t1,t3 where t1.a=t3.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary
|
||||
1 SIMPLE t3 ref a a 5 test.t1.a 1 Using index; Distinct
|
||||
select distinct t1.a from t1,t3 where t1.a=t3.a;
|
||||
a
|
||||
1
|
||||
2
|
||||
select distinct 1 from t1,t3 where t1.a=t3.a;
|
||||
1
|
||||
1
|
||||
explain SELECT distinct t1.a from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
|
||||
explain SELECT distinct t1.a from t1 order by a desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
|
||||
explain SELECT t1.a from t1 group by a order by a desc;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
|
||||
explain SELECT distinct t1.a from t1 order by a desc limit 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 1 Using index
|
||||
explain SELECT distinct a from t3 order by a desc limit 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 index NULL a 5 NULL 2 Using index
|
||||
explain SELECT distinct a,b from t3 order by a+1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
|
||||
explain SELECT distinct a,b from t3 order by a limit 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
|
||||
explain SELECT a,b from t3 group by a,b order by a+1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
|
||||
drop table t1,t2,t3,t4;
|
||||
CREATE TABLE t1 (name varchar(255));
|
||||
INSERT INTO t1 VALUES ('aa'),('ab'),('ac'),('ad'),('ae');
|
||||
SELECT DISTINCT * FROM t1 LIMIT 2;
|
||||
name
|
||||
aa
|
||||
ab
|
||||
SELECT DISTINCT name FROM t1 LIMIT 2;
|
||||
name
|
||||
aa
|
||||
ab
|
||||
SELECT DISTINCT 1 FROM t1 LIMIT 2;
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NAME varchar(75) DEFAULT '' NOT NULL,
|
||||
LINK_ID int(11) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY NAME (NAME),
|
||||
KEY LINK_ID (LINK_ID)
|
||||
);
|
||||
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0),(2,'Jack',0),(3,'Bill',0);
|
||||
CREATE TABLE t2 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NAME varchar(150) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY NAME (NAME)
|
||||
);
|
||||
SELECT DISTINCT
|
||||
t2.id AS key_link_id,
|
||||
t2.name AS link
|
||||
FROM t1
|
||||
LEFT JOIN t2 ON t1.link_id=t2.id
|
||||
GROUP BY t1.id
|
||||
ORDER BY link;
|
||||
key_link_id link
|
||||
NULL NULL
|
||||
drop table t1,t2;
|
||||
create table t1 (
|
||||
id int not null,
|
||||
name tinytext not null,
|
||||
unique (id)
|
||||
);
|
||||
create table t2 (
|
||||
id int not null,
|
||||
idx int not null,
|
||||
unique (id, idx)
|
||||
);
|
||||
create table t3 (
|
||||
id int not null,
|
||||
idx int not null,
|
||||
unique (id, idx)
|
||||
);
|
||||
insert into t1 values (1,'yes'), (2,'no');
|
||||
insert into t2 values (1,1);
|
||||
insert into t3 values (1,1);
|
||||
set @save_join_cache_level=@@join_cache_level;
|
||||
set join_cache_level=1;
|
||||
EXPLAIN
|
||||
SELECT DISTINCT
|
||||
t1.id
|
||||
from
|
||||
t1
|
||||
straight_join
|
||||
t2
|
||||
straight_join
|
||||
t3
|
||||
straight_join
|
||||
t1 as j_lj_t2 left join t2 as t2_lj
|
||||
on j_lj_t2.id=t2_lj.id
|
||||
straight_join
|
||||
t1 as j_lj_t3 left join t3 as t3_lj
|
||||
on j_lj_t3.id=t3_lj.id
|
||||
WHERE
|
||||
((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2))
|
||||
AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index id id 4 NULL 2 Using index; Using temporary
|
||||
1 SIMPLE t2 index id id 8 NULL 1 Using index; Distinct; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 index id id 8 NULL 1 Using index; Distinct; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t2_lj ref id id 4 test.j_lj_t2.id 1 Using where; Using index; Distinct
|
||||
1 SIMPLE j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3_lj ref id id 4 test.j_lj_t3.id 1 Using where; Using index; Distinct
|
||||
SELECT DISTINCT
|
||||
t1.id
|
||||
from
|
||||
t1
|
||||
straight_join
|
||||
t2
|
||||
straight_join
|
||||
t3
|
||||
straight_join
|
||||
t1 as j_lj_t2 left join t2 as t2_lj
|
||||
on j_lj_t2.id=t2_lj.id
|
||||
straight_join
|
||||
t1 as j_lj_t3 left join t3 as t3_lj
|
||||
on j_lj_t3.id=t3_lj.id
|
||||
WHERE
|
||||
((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2))
|
||||
AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
|
||||
id
|
||||
2
|
||||
drop table t1,t2,t3;
|
||||
set join_cache_level=@save_join_cache_level;
|
||||
create table t1 (a int not null, b int not null, t time);
|
||||
insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15");
|
||||
select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b;
|
||||
a sec_to_time(sum(time_to_sec(t)))
|
||||
1 00:06:15
|
||||
1 00:36:30
|
||||
1 00:36:30
|
||||
select distinct a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b;
|
||||
a sec_to_time(sum(time_to_sec(t)))
|
||||
1 00:06:15
|
||||
1 00:36:30
|
||||
create table t2 (a int not null primary key, b int);
|
||||
insert into t2 values (1,1),(2,2),(3,3);
|
||||
select t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b;
|
||||
a sec_to_time(sum(time_to_sec(t)))
|
||||
1 00:06:15
|
||||
1 00:36:30
|
||||
1 00:36:30
|
||||
select distinct t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b;
|
||||
a sec_to_time(sum(time_to_sec(t)))
|
||||
1 00:06:15
|
||||
1 00:36:30
|
||||
drop table t1,t2;
|
||||
create table t1 (a int not null,b char(5), c text);
|
||||
insert into t1 (a) values (1),(2),(3),(4),(1),(2),(3),(4);
|
||||
select distinct a from t1 group by b,a having a > 2 order by a desc;
|
||||
a
|
||||
4
|
||||
3
|
||||
select distinct a,c from t1 group by b,c,a having a > 2 order by a desc;
|
||||
a c
|
||||
4 NULL
|
||||
3 NULL
|
||||
drop table t1;
|
||||
create table t1 (a char(1), key(a)) engine=myisam;
|
||||
insert into t1 values('1'),('1');
|
||||
select * from t1 where a >= '1';
|
||||
a
|
||||
1
|
||||
1
|
||||
select distinct a from t1 order by a desc;
|
||||
a
|
||||
1
|
||||
select distinct a from t1 where a >= '1' order by a desc;
|
||||
a
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (email varchar(50), infoID BIGINT, dateentered DATETIME);
|
||||
CREATE TABLE t2 (infoID BIGINT, shipcode varchar(10));
|
||||
INSERT INTO t1 (email, infoID, dateentered) VALUES
|
||||
('test1@testdomain.com', 1, '2002-07-30 22:56:38'),
|
||||
('test1@testdomain.com', 1, '2002-07-27 22:58:16'),
|
||||
('test2@testdomain.com', 1, '2002-06-19 15:22:19'),
|
||||
('test2@testdomain.com', 2, '2002-06-18 14:23:47'),
|
||||
('test3@testdomain.com', 1, '2002-05-19 22:17:32');
|
||||
INSERT INTO t2(infoID, shipcode) VALUES
|
||||
(1, 'Z001'),
|
||||
(2, 'R002');
|
||||
SELECT DISTINCTROW email, shipcode FROM t1, t2 WHERE t1.infoID=t2.infoID;
|
||||
email shipcode
|
||||
test1@testdomain.com Z001
|
||||
test2@testdomain.com Z001
|
||||
test2@testdomain.com R002
|
||||
test3@testdomain.com Z001
|
||||
SELECT DISTINCTROW email FROM t1 ORDER BY dateentered DESC;
|
||||
email
|
||||
test1@testdomain.com
|
||||
test2@testdomain.com
|
||||
test3@testdomain.com
|
||||
SELECT DISTINCTROW email, shipcode FROM t1, t2 WHERE t1.infoID=t2.infoID ORDER BY dateentered DESC;
|
||||
email shipcode
|
||||
test1@testdomain.com Z001
|
||||
test2@testdomain.com Z001
|
||||
test2@testdomain.com R002
|
||||
test3@testdomain.com Z001
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (privatemessageid int(10) unsigned NOT NULL auto_increment, folderid smallint(6) NOT NULL default '0', userid int(10) unsigned NOT NULL default '0', touserid int(10) unsigned NOT NULL default '0', fromuserid int(10) unsigned NOT NULL default '0', title varchar(250) NOT NULL default '', message mediumtext NOT NULL, dateline int(10) unsigned NOT NULL default '0', showsignature smallint(6) NOT NULL default '0', iconid smallint(5) unsigned NOT NULL default '0', messageread smallint(6) NOT NULL default '0', readtime int(10) unsigned NOT NULL default '0', receipt smallint(6) unsigned NOT NULL default '0', deleteprompt smallint(6) unsigned NOT NULL default '0', multiplerecipients smallint(6) unsigned NOT NULL default '0', PRIMARY KEY (privatemessageid), KEY userid (userid)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (128,0,33,33,8,':D','',996121863,1,0,2,996122850,2,0,0);
|
||||
CREATE TABLE t2 (userid int(10) unsigned NOT NULL auto_increment, usergroupid smallint(5) unsigned NOT NULL default '0', username varchar(50) NOT NULL default '', password varchar(50) NOT NULL default '', email varchar(50) NOT NULL default '', styleid smallint(5) unsigned NOT NULL default '0', parentemail varchar(50) NOT NULL default '', coppauser smallint(6) NOT NULL default '0', homepage varchar(100) NOT NULL default '', icq varchar(20) NOT NULL default '', aim varchar(20) NOT NULL default '', yahoo varchar(20) NOT NULL default '', signature mediumtext NOT NULL, adminemail smallint(6) NOT NULL default '0', showemail smallint(6) NOT NULL default '0', invisible smallint(6) NOT NULL default '0', usertitle varchar(250) NOT NULL default '', customtitle smallint(6) NOT NULL default '0', joindate int(10) unsigned NOT NULL default '0', cookieuser smallint(6) NOT NULL default '0', daysprune smallint(6) NOT NULL default '0', lastvisit int(10) unsigned NOT NULL default '0', lastactivity int(10) unsigned NOT NULL default '0', lastpost int(10) unsigned NOT NULL default '0', posts smallint(5) unsigned NOT NULL default '0', timezoneoffset varchar(4) NOT NULL default '', emailnotification smallint(6) NOT NULL default '0', buddylist mediumtext NOT NULL, ignorelist mediumtext NOT NULL, pmfolders mediumtext NOT NULL, receivepm smallint(6) NOT NULL default '0', emailonpm smallint(6) NOT NULL default '0', pmpopup smallint(6) NOT NULL default '0', avatarid smallint(6) NOT NULL default '0', avatarrevision int(6) unsigned NOT NULL default '0', options smallint(6) NOT NULL default '15', birthday date NOT NULL default '0000-00-00', maxposts smallint(6) NOT NULL default '-1', startofweek smallint(6) NOT NULL default '1', ipaddress varchar(20) NOT NULL default '', referrerid int(10) unsigned NOT NULL default '0', nosessionhash smallint(6) NOT NULL default '0', autorefresh smallint(6) NOT NULL default '-1', messagepopup tinyint(2) NOT NULL default '0', inforum smallint(5) unsigned NOT NULL default '0', ratenum smallint(5) unsigned NOT NULL default '0', ratetotal smallint(5) unsigned NOT NULL default '0', allowrate smallint(5) unsigned NOT NULL default '1', PRIMARY KEY (userid), KEY usergroupid (usergroupid), KEY username (username), KEY inforum (inforum)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (33,6,'Kevin','0','kevin@stileproject.com',1,'',0,'http://www.stileproject.com','','','','',1,1,0,'Administrator',0,996120694,1,-1,1030996168,1031027028,1030599436,36,'-6',0,'','','',1,0,1,0,0,15,'0000-00-00',-1,1,'64.0.0.0',0,1,-1,0,0,4,19,1);
|
||||
SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid);
|
||||
privatemessageid folderid userid touserid fromuserid title message dateline showsignature iconid messageread readtime receipt deleteprompt multiplerecipients userid usergroupid username password email styleid parentemail coppauser homepage icq aim yahoo signature adminemail showemail invisible usertitle customtitle joindate cookieuser daysprune lastvisit lastactivity lastpost posts timezoneoffset emailnotification buddylist ignorelist pmfolders receivepm emailonpm pmpopup avatarid avatarrevision options birthday maxposts startofweek ipaddress referrerid nosessionhash autorefresh messagepopup inforum ratenum ratetotal allowrate
|
||||
128 0 33 33 8 :D 996121863 1 0 2 996122850 2 0 0 33 6 Kevin 0 kevin@stileproject.com 1 0 http://www.stileproject.com 1 1 0 Administrator 0 996120694 1 -1 1030996168 1031027028 1030599436 36 -6 0 1 0 1 0 0 15 0000-00-00 -1 1 64.0.0.0 0 1 -1 0 0 4 19 1
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a int primary key, b int, c int);
|
||||
INSERT t1 VALUES (1,2,3);
|
||||
CREATE TABLE t2 (a int primary key, b int, c int);
|
||||
INSERT t2 VALUES (3,4,5);
|
||||
SELECT DISTINCT t1.a, t2.b FROM t1, t2 WHERE t1.a=1 ORDER BY t2.c;
|
||||
a b
|
||||
1 4
|
||||
DROP TABLE t1,t2;
|
||||
CREATE table t1 ( `id` int(11) NOT NULL auto_increment, `name` varchar(50) NOT NULL default '', PRIMARY KEY (`id`)) ENGINE=MyISAM AUTO_INCREMENT=3 ;
|
||||
INSERT INTO t1 VALUES (1, 'aaaaa');
|
||||
INSERT INTO t1 VALUES (3, 'aaaaa');
|
||||
INSERT INTO t1 VALUES (2, 'eeeeeee');
|
||||
select distinct left(name,1) as name from t1;
|
||||
name
|
||||
a
|
||||
e
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NAME varchar(75) DEFAULT '' NOT NULL,
|
||||
LINK_ID int(11) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY NAME (NAME),
|
||||
KEY LINK_ID (LINK_ID)
|
||||
);
|
||||
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0);
|
||||
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0);
|
||||
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0);
|
||||
CREATE TABLE t2 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NAME varchar(150) DEFAULT '' NOT NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY NAME (NAME)
|
||||
);
|
||||
SELECT DISTINCT
|
||||
t2.id AS key_link_id,
|
||||
t2.name AS link
|
||||
FROM t1
|
||||
LEFT JOIN t2 ON t1.link_id=t2.id
|
||||
GROUP BY t1.id
|
||||
ORDER BY link;
|
||||
key_link_id link
|
||||
NULL NULL
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
html varchar(5) default NULL,
|
||||
rin int(11) default '0',
|
||||
rout int(11) default '0'
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('1',1,0);
|
||||
SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
|
||||
html prod
|
||||
1 0.0000
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
|
||||
SELECT DISTINCT a, 1 FROM t1;
|
||||
a 1
|
||||
1 1
|
||||
2 1
|
||||
3 1
|
||||
4 1
|
||||
5 1
|
||||
SELECT DISTINCT 1, a FROM t1;
|
||||
1 a
|
||||
1 1
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES (1,1),(2,2),(2,3),(2,4),(3,5);
|
||||
SELECT DISTINCT a, b, 2 FROM t2;
|
||||
a b 2
|
||||
1 1 2
|
||||
2 2 2
|
||||
2 3 2
|
||||
2 4 2
|
||||
3 5 2
|
||||
SELECT DISTINCT 2, a, b FROM t2;
|
||||
2 a b
|
||||
2 1 1
|
||||
2 2 2
|
||||
2 2 3
|
||||
2 2 4
|
||||
2 3 5
|
||||
SELECT DISTINCT a, 2, b FROM t2;
|
||||
a 2 b
|
||||
1 2 1
|
||||
2 2 2
|
||||
2 2 3
|
||||
2 2 4
|
||||
3 2 5
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1(a INT PRIMARY KEY, b INT);
|
||||
INSERT INTO t1 VALUES (1,1), (2,1), (3,1);
|
||||
EXPLAIN SELECT DISTINCT a FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT a,b FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1_1 ALL NULL NULL NULL NULL 3 Using temporary
|
||||
1 SIMPLE t1_2 index NULL PRIMARY 4 NULL 3 Using index; Distinct; Using join buffer (flat, BNL join)
|
||||
EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2
|
||||
WHERE t1_1.a = t1_2.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1_1 ALL PRIMARY NULL NULL NULL 3 Using temporary
|
||||
1 SIMPLE t1_2 eq_ref PRIMARY PRIMARY 4 test.t1_1.a 1 Using index; Distinct
|
||||
EXPLAIN SELECT a FROM t1 GROUP BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
|
||||
EXPLAIN SELECT a,b FROM t1 GROUP BY a,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
EXPLAIN SELECT DISTINCT a,b FROM t1 GROUP BY a,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
CREATE TABLE t2(a INT, b INT, c INT, d INT, PRIMARY KEY (a,b));
|
||||
INSERT INTO t2 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
|
||||
EXPLAIN SELECT DISTINCT a FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT a,a FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT b,a FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
|
||||
EXPLAIN SELECT DISTINCT a,c FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using temporary
|
||||
EXPLAIN SELECT DISTINCT c,a,b FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
|
||||
EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
|
||||
CREATE UNIQUE INDEX c_b_unq ON t2 (c,b);
|
||||
EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
|
||||
DROP TABLE t1,t2;
|
||||
create table t1 (id int, dsc varchar(50));
|
||||
insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three");
|
||||
select distinct id, IFNULL(dsc, '-') from t1;
|
||||
id IFNULL(dsc, '-')
|
||||
1 line number one
|
||||
2 line number two
|
||||
3 line number three
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int primary key, b int);
|
||||
INSERT INTO t1 (a,b) values (1,1), (2,3), (3,2);
|
||||
explain SELECT DISTINCT a, b FROM t1 ORDER BY b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
SELECT DISTINCT a, b FROM t1 ORDER BY b;
|
||||
a b
|
||||
1 1
|
||||
3 2
|
||||
2 3
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
x varchar(20) default NULL,
|
||||
y decimal(10,0) default NULL,
|
||||
PRIMARY KEY (ID),
|
||||
KEY (y)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES
|
||||
(1,'ba','-1'),
|
||||
(2,'ba','1150'),
|
||||
(306,'ba','-1'),
|
||||
(307,'ba','1150'),
|
||||
(611,'ba','-1'),
|
||||
(612,'ba','1150');
|
||||
select count(distinct x,y) from t1;
|
||||
count(distinct x,y)
|
||||
2
|
||||
select count(distinct concat(x,y)) from t1;
|
||||
count(distinct concat(x,y))
|
||||
2
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b));
|
||||
INSERT INTO t1 VALUES (1, 101);
|
||||
INSERT INTO t1 SELECT a + 1, a + 101 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 2, a + 102 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 4, a + 104 FROM t1;
|
||||
INSERT INTO t1 SELECT a + 8, a + 108 FROM t1;
|
||||
EXPLAIN SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 8 NULL 16 Using where; Using index
|
||||
SELECT DISTINCT a,a FROM t1 WHERE b < 12 ORDER BY a;
|
||||
a a
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a CHAR(1));
|
||||
INSERT INTO t1 VALUES('A'), (0);
|
||||
SELECT a FROM t1 WHERE a=0;
|
||||
a
|
||||
A
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'A'
|
||||
SELECT DISTINCT a FROM t1 WHERE a=0;
|
||||
a
|
||||
A
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'A'
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a DATE);
|
||||
INSERT INTO t1 VALUES ('1972-07-29'), ('1972-02-06');
|
||||
EXPLAIN SELECT (SELECT DISTINCT a FROM t1 WHERE a = '2002-08-03');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
EXPLAIN SELECT (SELECT DISTINCT ADDDATE(a,1) FROM t1
|
||||
WHERE ADDDATE(a,1) = '2002-08-03');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
CREATE TABLE t2 (a CHAR(5) CHARACTER SET latin1 COLLATE latin1_general_ci);
|
||||
INSERT INTO t2 VALUES (0xf6);
|
||||
INSERT INTO t2 VALUES ('oe');
|
||||
SELECT COUNT(*) FROM (SELECT DISTINCT a FROM t2) dt;
|
||||
COUNT(*)
|
||||
2
|
||||
SELECT COUNT(*) FROM
|
||||
(SELECT DISTINCT a FROM t2 WHERE a='oe' COLLATE latin1_german2_ci) dt;
|
||||
COUNT(*)
|
||||
2
|
||||
DROP TABLE t1, t2;
|
@ -1,93 +0,0 @@
|
||||
drop table if exists t1;
|
||||
drop database if exists mysqltest;
|
||||
drop database if exists client_test_db;
|
||||
drop table t1;
|
||||
ERROR 42S02: Unknown table 't1'
|
||||
create table t1(n int);
|
||||
insert into t1 values(1);
|
||||
create temporary table t1( n int);
|
||||
insert into t1 values(2);
|
||||
create table t1(n int);
|
||||
ERROR 42S01: Table 't1' already exists
|
||||
drop table t1;
|
||||
select * from t1;
|
||||
n
|
||||
1
|
||||
create database mysqltest;
|
||||
drop database if exists mysqltest;
|
||||
create database mysqltest;
|
||||
create table mysqltest.mysqltest (n int);
|
||||
insert into mysqltest.mysqltest values (4);
|
||||
select * from mysqltest.mysqltest;
|
||||
n
|
||||
4
|
||||
drop database if exists mysqltest;
|
||||
affected rows: 1
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
drop table table1, table2, table3, table4, table5, table6,
|
||||
table7, table8, table9, table10, table11, table12, table13,
|
||||
table14, table15, table16, table17, table18, table19, table20,
|
||||
table21, table22, table23, table24, table25, table26, table27,
|
||||
table28;
|
||||
ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table'
|
||||
drop table table1, table2, table3, table4, table5, table6,
|
||||
table7, table8, table9, table10, table11, table12, table13,
|
||||
table14, table15, table16, table17, table18, table19, table20,
|
||||
table21, table22, table23, table24, table25, table26, table27,
|
||||
table28, table29, table30;
|
||||
ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table'
|
||||
use test;
|
||||
drop database mysqltest;
|
||||
flush tables with read lock;
|
||||
create database mysqltest;
|
||||
Got one of the listed errors
|
||||
unlock tables;
|
||||
create database mysqltest;
|
||||
show databases;
|
||||
Database
|
||||
information_schema
|
||||
mtr
|
||||
mysql
|
||||
mysqltest
|
||||
pbxt
|
||||
performance_schema
|
||||
test
|
||||
flush tables with read lock;
|
||||
drop database mysqltest;
|
||||
Got one of the listed errors
|
||||
unlock tables;
|
||||
drop database mysqltest;
|
||||
show databases;
|
||||
Database
|
||||
information_schema
|
||||
mtr
|
||||
mysql
|
||||
pbxt
|
||||
performance_schema
|
||||
test
|
||||
drop database mysqltest;
|
||||
ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist
|
||||
drop table t1;
|
||||
flush tables with read lock;
|
||||
create table t1(n int);
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
unlock tables;
|
||||
create table t1(n int);
|
||||
show tables;
|
||||
Tables_in_test
|
||||
t1
|
||||
drop table t1;
|
||||
drop database if exists mysqltest;
|
||||
drop table if exists t1;
|
||||
create table t1 (i int);
|
||||
create database mysqltest;
|
||||
lock tables t1 read;
|
||||
drop table t1;
|
||||
show open tables;
|
||||
drop database mysqltest;
|
||||
select 1;
|
||||
1
|
||||
1
|
||||
unlock tables;
|
||||
End of 5.0 tests
|
@ -1,10 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
0
|
||||
select * from t1;
|
||||
nr b str
|
||||
select * from t1 limit 0;
|
||||
nr b str
|
||||
drop table t1;
|
@ -1,220 +0,0 @@
|
||||
drop table if exists t1;
|
||||
select 'a' = 'a', 'a' = 'a ', 'a ' = 'a';
|
||||
'a' = 'a' 'a' = 'a ' 'a ' = 'a'
|
||||
1 1 1
|
||||
select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a';
|
||||
'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a'
|
||||
0 1 0
|
||||
select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0';
|
||||
'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0'
|
||||
0 0 1
|
||||
select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a ';
|
||||
'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a '
|
||||
0 1 0
|
||||
select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0';
|
||||
'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0'
|
||||
0 0 1
|
||||
select 'a a' > 'a', 'a \0' < 'a';
|
||||
'a a' > 'a' 'a \0' < 'a'
|
||||
1 1
|
||||
select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a';
|
||||
binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a'
|
||||
1 1 1
|
||||
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1));
|
||||
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select * from t1 ignore key (key1) where text1='teststring' or
|
||||
text1 like 'teststring_%' ORDER BY text1;
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
text1
|
||||
teststring
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
explain select * from t1 order by text1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL key1 34 NULL 3 Using index
|
||||
alter table t1 modify text1 char(32) binary not null;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select * from t1 ignore key (key1) where text1='teststring' or
|
||||
text1 like 'teststring_%' ORDER BY text1;
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring|
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
select text1, length(text1) from t1 order by text1;
|
||||
text1 length(text1)
|
||||
nothing 7
|
||||
teststring 11
|
||||
teststring 10
|
||||
select text1, length(text1) from t1 order by binary text1;
|
||||
text1 length(text1)
|
||||
nothing 7
|
||||
teststring 10
|
||||
teststring 11
|
||||
alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20));
|
||||
insert into t1 values ('teststring ');
|
||||
select concat('|', text1, '|') from t1 order by text1;
|
||||
concat('|', text1, '|')
|
||||
|nothing|
|
||||
|teststring|
|
||||
|teststring |
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
select concat('|', text1, '|') from t1 where text1='teststring ';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
alter table t1 modify text1 text not null, pack_keys=1;
|
||||
select concat('|', text1, '|') from t1 where text1='teststring';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring ';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
|teststring |
|
||||
explain select concat('|', text1, '|') from t1 where text1='teststring ';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref key1 key1 22 const 1 Using where
|
||||
select concat('|', text1, '|') from t1 where text1 like 'teststring_%';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring|
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
concat('|', text1, '|')
|
||||
|teststring|
|
||||
|teststring |
|
||||
select concat('|', text1, '|') from t1 order by text1;
|
||||
concat('|', text1, '|')
|
||||
|nothing|
|
||||
|teststring |
|
||||
|teststring|
|
||||
|teststring |
|
||||
drop table t1;
|
||||
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) pack_keys=0;
|
||||
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring|
|
||||
select concat('|', text1, '|') from t1 where text1='teststring' or text1 >= 'teststring\t';
|
||||
concat('|', text1, '|')
|
||||
|teststring |
|
||||
|teststring|
|
||||
drop table t1;
|
||||
create table t1 (text1 varchar(32) not NULL, KEY key1 using BTREE (text1)) engine=heap;
|
||||
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
|
||||
select * from t1 ignore key (key1) where text1='teststring' or
|
||||
text1 like 'teststring_%' ORDER BY text1;
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 >= 'teststring\t';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
explain select * from t1 order by text1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
alter table t1 modify text1 char(32) binary not null;
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
drop table t1;
|
||||
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) engine=innodb;
|
||||
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
select * from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select * from t1 where text1='teststring' or text1 > 'teststring\t';
|
||||
text1
|
||||
teststring
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
explain select * from t1 order by text1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL key1 34 NULL 3 Using index
|
||||
alter table t1 modify text1 char(32) binary not null;
|
||||
select * from t1 order by text1;
|
||||
text1
|
||||
nothing
|
||||
teststring
|
||||
teststring
|
||||
alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20));
|
||||
insert into t1 values ('teststring ');
|
||||
select concat('|', text1, '|') from t1 order by text1;
|
||||
concat('|', text1, '|')
|
||||
|nothing|
|
||||
|teststring|
|
||||
|teststring |
|
||||
|teststring |
|
||||
alter table t1 modify text1 text not null, pack_keys=1;
|
||||
select * from t1 where text1 like 'teststring_%';
|
||||
text1
|
||||
teststring
|
||||
teststring
|
||||
select text1, length(text1) from t1 where text1='teststring' or text1 like 'teststring_%';
|
||||
text1 length(text1)
|
||||
teststring 11
|
||||
teststring 10
|
||||
teststring 11
|
||||
select text1, length(text1) from t1 where text1='teststring' or text1 >= 'teststring\t';
|
||||
text1 length(text1)
|
||||
teststring 11
|
||||
teststring 10
|
||||
teststring 11
|
||||
select concat('|', text1, '|') from t1 order by text1;
|
||||
concat('|', text1, '|')
|
||||
|nothing|
|
||||
|teststring |
|
||||
|teststring|
|
||||
|teststring |
|
||||
drop table t1;
|
@ -1,30 +0,0 @@
|
||||
drop table if exists t1;
|
||||
insert into t1 values(1);
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
delete from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
update t1 set a=1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
create table t1 (a int);
|
||||
select count(test.t1.b) from t1;
|
||||
ERROR 42S22: Unknown column 'test.t1.b' in 'field list'
|
||||
select count(not_existing_database.t1) from t1;
|
||||
ERROR 42S22: Unknown column 'not_existing_database.t1' in 'field list'
|
||||
select count(not_existing_database.t1.a) from t1;
|
||||
ERROR 42S22: Unknown column 'not_existing_database.t1.a' in 'field list'
|
||||
select count(not_existing_database.t1.a) from not_existing_database.t1;
|
||||
Got one of the listed errors
|
||||
select 1 from t1 order by 2;
|
||||
ERROR 42S22: Unknown column '2' in 'order clause'
|
||||
select 1 from t1 group by 2;
|
||||
ERROR 42S22: Unknown column '2' in 'group statement'
|
||||
select 1 from t1 order by t1.b;
|
||||
ERROR 42S22: Unknown column 't1.b' in 'order clause'
|
||||
select count(*),b from t1;
|
||||
ERROR 42S22: Unknown column 'b' in 'field list'
|
||||
drop table t1;
|
||||
create table t1 (a int(256));
|
||||
ERROR 42000: Display width out of range for 'a' (max = 255)
|
||||
set sql_mode='traditional';
|
||||
create table t1 (a varchar(66000));
|
||||
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
|
@ -1,59 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (id int not null, str char(10), unique(str));
|
||||
explain select * from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 0
|
||||
insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar");
|
||||
select * from t1 where str is null;
|
||||
id str
|
||||
1 NULL
|
||||
2 NULL
|
||||
select * from t1 where str="foo";
|
||||
id str
|
||||
3 foo
|
||||
explain select * from t1 where str is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref str str 11 const 1 Using where
|
||||
explain select * from t1 where str="foo";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const str str 11 const 1
|
||||
explain select * from t1 ignore key (str) where str="foo";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
explain select * from t1 use key (str,str) where str="foo";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const str str 11 const 1
|
||||
explain select * from t1 use key (str,str,foo) where str="foo";
|
||||
ERROR 42000: Key 'foo' doesn't exist in table 't1'
|
||||
explain select * from t1 ignore key (str,str,foo) where str="foo";
|
||||
ERROR 42000: Key 'foo' doesn't exist in table 't1'
|
||||
drop table t1;
|
||||
explain select 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
create table t1 (a int not null);
|
||||
explain select count(*) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 0
|
||||
insert into t1 values(1);
|
||||
explain select count(*) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1
|
||||
insert into t1 values(1);
|
||||
explain select count(*) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
|
||||
drop table t1;
|
||||
set names koi8r;
|
||||
create table ÔÁÂ (ËÏÌ0 int, ËÏÌ1 int, key ÉÎÄ0 (ËÏÌ0), key ÉÎÄ01 (ËÏÌ0,ËÏÌ1));
|
||||
insert into ÔÁÂ (ËÏÌ0) values (1);
|
||||
insert into ÔÁÂ (ËÏÌ0) values (2);
|
||||
explain select ËÏÌ0 from ÔÁÂ where ËÏÌ0=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE ÔÁÂ ref ÉÎÄ0,ÉÎÄ01 ÉÎÄ0 5 const 1 Using index
|
||||
drop table ÔÁÂ;
|
||||
set names latin1;
|
||||
select 3 into @v1;
|
||||
explain select 3 into @v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
|
@ -1,61 +0,0 @@
|
||||
drop table if exists t1,t2;
|
||||
drop database if exists mysqltest;
|
||||
create temporary table t1(n int not null primary key);
|
||||
create table t2(n int);
|
||||
insert into t2 values(3);
|
||||
select * from t1;
|
||||
n
|
||||
3
|
||||
flush tables with read lock;
|
||||
drop table t2;
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
drop table t2;
|
||||
unlock tables;
|
||||
create database mysqltest;
|
||||
create table mysqltest.t1(n int);
|
||||
insert into mysqltest.t1 values (23);
|
||||
flush tables with read lock;
|
||||
drop database mysqltest;
|
||||
select * from mysqltest.t1;
|
||||
n
|
||||
23
|
||||
unlock tables;
|
||||
create table t1 (n int);
|
||||
flush tables with read lock;
|
||||
insert into t1 values (345);
|
||||
select * from t1;
|
||||
n
|
||||
345
|
||||
drop table t1;
|
||||
create table t1 (c1 int);
|
||||
lock table t1 write;
|
||||
flush tables with read lock;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
lock table t1 read;
|
||||
flush tables with read lock;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
unlock tables;
|
||||
flush tables with read lock;
|
||||
lock table t1 write;
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
lock table t1 read;
|
||||
lock table t1 write;
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
unlock tables;
|
||||
create table t2 (c1 int);
|
||||
create table t3 (c1 int);
|
||||
lock table t1 read, t2 read, t3 write;
|
||||
flush tables with read lock;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
lock table t1 read, t2 read, t3 read;
|
||||
flush tables with read lock;
|
||||
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
||||
unlock tables;
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (c1 int);
|
||||
create table t2 (c1 int);
|
||||
lock table t1 write;
|
||||
flush tables with read lock;
|
||||
insert into t2 values(1);
|
||||
unlock tables;
|
||||
drop table t1, t2;
|
@ -1,12 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (kill_id int);
|
||||
insert into t1 values(connection_id());
|
||||
select kill_id-kill_id from t1;
|
||||
kill_id-kill_id
|
||||
0
|
||||
flush tables with read lock;
|
||||
select ((@id := kill_id) - kill_id) from t1;
|
||||
((@id := kill_id) - kill_id)
|
||||
0
|
||||
kill connection @id;
|
||||
drop table t1;
|
@ -1,130 +0,0 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (a int not null auto_increment primary key);
|
||||
insert into t1 values(0);
|
||||
lock table t1 read;
|
||||
flush table t1;
|
||||
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
|
||||
unlock tables;
|
||||
lock table t1 write;
|
||||
flush table t1;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
unlock tables;
|
||||
lock table t1 write;
|
||||
lock table t1 read;
|
||||
flush table t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
unlock tables;
|
||||
unlock tables;
|
||||
lock table t1 write;
|
||||
lock table t1 write;
|
||||
flush table t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
unlock tables;
|
||||
unlock tables;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
drop table t1;
|
||||
create table t1(table_id char(20) primary key);
|
||||
create table t2(table_id char(20) primary key);
|
||||
insert into t1 values ('test.t1');
|
||||
insert into t1 values ('');
|
||||
insert into t2 values ('test.t2');
|
||||
insert into t2 values ('');
|
||||
handler t1 open as a1;
|
||||
handler t1 open as a2;
|
||||
handler t2 open;
|
||||
handler a1 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler a2 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler t2 read first limit 9;
|
||||
table_id
|
||||
test.t2
|
||||
|
||||
flush tables;
|
||||
handler a1 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler a2 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler t2 read first limit 9;
|
||||
table_id
|
||||
test.t2
|
||||
|
||||
handler t1 open as a1;
|
||||
ERROR 42000: Not unique table/alias: 'a1'
|
||||
handler t1 open as a2;
|
||||
ERROR 42000: Not unique table/alias: 'a2'
|
||||
handler t2 open;
|
||||
ERROR 42000: Not unique table/alias: 't2'
|
||||
handler a1 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler a2 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler t2 read first limit 9;
|
||||
table_id
|
||||
test.t2
|
||||
|
||||
flush table t1;
|
||||
handler a1 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler a2 read first limit 9;
|
||||
table_id
|
||||
test.t1
|
||||
|
||||
handler t2 read first limit 9;
|
||||
table_id
|
||||
test.t2
|
||||
|
||||
flush table t2;
|
||||
handler t2 close;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table t1(table_id char(20) primary key);
|
||||
insert into t1 values ('Record-01');
|
||||
insert into t1 values ('Record-02');
|
||||
insert into t1 values ('Record-03');
|
||||
insert into t1 values ('Record-04');
|
||||
insert into t1 values ('Record-05');
|
||||
handler t1 open;
|
||||
handler t1 read first limit 1;
|
||||
table_id
|
||||
Record-01
|
||||
handler t1 read next limit 1;
|
||||
table_id
|
||||
Record-02
|
||||
handler t1 read next limit 1;
|
||||
table_id
|
||||
Record-03
|
||||
flush table t1;
|
||||
handler t1 read next limit 1;
|
||||
table_id
|
||||
Record-01
|
||||
handler t1 read next limit 1;
|
||||
table_id
|
||||
Record-02
|
||||
handler t1 close;
|
||||
drop table t1;
|
||||
FLUSH TABLES WITH READ LOCK ;
|
||||
FLUSH TABLES WITH READ LOCK ;
|
||||
UNLOCK TABLES;
|
@ -1,18 +0,0 @@
|
||||
drop table if exists t1;
|
||||
set foreign_key_checks = 0;
|
||||
create table t1 (
|
||||
a int not null references t2,
|
||||
b int not null references t2 (c),
|
||||
c int,
|
||||
primary key (a,b),
|
||||
foreign key (a) references t3 match full,
|
||||
foreign key (a) references t3 match partial,
|
||||
foreign key (a,b) references t3 (c,d) on delete no action
|
||||
on update no action,
|
||||
foreign key (a,b) references t3 (c,d) on update cascade,
|
||||
foreign key (a,b) references t3 (c,d) on delete set default,
|
||||
foreign key (c) references t3 (e) on update set null);
|
||||
create index a on t1 (a);
|
||||
create unique index b on t1 (a,b);
|
||||
drop table t1;
|
||||
set foreign_key_checks = 1;
|
@ -1,84 +0,0 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 ( number INT NOT NULL, alpha CHAR(6) NOT NULL );
|
||||
INSERT INTO t1 VALUES (1413006,'idlfmv'),
|
||||
(1413065,'smpsfz'),(1413127,'sljrhx'),(1413304,'qerfnd');
|
||||
SELECT number, alpha, CONCAT_WS('<---->',number,alpha) AS new
|
||||
FROM t1 GROUP BY number;
|
||||
number alpha new
|
||||
1413006 idlfmv 1413006<---->idlfmv
|
||||
1413065 smpsfz 1413065<---->smpsfz
|
||||
1413127 sljrhx 1413127<---->sljrhx
|
||||
1413304 qerfnd 1413304<---->qerfnd
|
||||
SELECT CONCAT_WS('<---->',number,alpha) AS new
|
||||
FROM t1 GROUP BY new LIMIT 1;
|
||||
new
|
||||
1413006<---->idlfmv
|
||||
SELECT number, alpha, CONCAT_WS('<->',number,alpha) AS new
|
||||
FROM t1 GROUP BY new LIMIT 1;
|
||||
number alpha new
|
||||
1413006 idlfmv 1413006<->idlfmv
|
||||
SELECT number, alpha, CONCAT_WS('-',number,alpha,alpha,alpha,alpha,alpha,alpha,alpha) AS new
|
||||
FROM t1 GROUP BY new LIMIT 1;
|
||||
number alpha new
|
||||
1413006 idlfmv 1413006-idlfmv-idlfmv-idlfmv-idlfmv-idlfmv-idlfmv-idlfmv
|
||||
SELECT number, alpha, CONCAT_WS('<------------------>',number,alpha) AS new
|
||||
FROM t1 GROUP BY new LIMIT 1;
|
||||
number alpha new
|
||||
1413006 idlfmv 1413006<------------------>idlfmv
|
||||
drop table t1;
|
||||
create table t1 (a char(4), b double, c date, d tinyint(4));
|
||||
insert into t1 values ('AAAA', 105, '2003-03-01', 1);
|
||||
select * from t1 where concat(A,C,B,D) = 'AAAA2003-03-011051';
|
||||
a b c d
|
||||
AAAA 105 2003-03-01 1
|
||||
drop table t1;
|
||||
select 'a' union select concat('a', -4);
|
||||
a
|
||||
a
|
||||
a-4
|
||||
select 'a' union select concat('a', -4.5);
|
||||
a
|
||||
a
|
||||
a-4.5
|
||||
select 'a' union select concat('a', -(4 + 1));
|
||||
a
|
||||
a
|
||||
a-5
|
||||
select 'a' union select concat('a', 4 - 5);
|
||||
a
|
||||
a
|
||||
a-1
|
||||
select 'a' union select concat('a', -'3');
|
||||
a
|
||||
a
|
||||
a-3
|
||||
select 'a' union select concat('a', -concat('3',4));
|
||||
a
|
||||
a
|
||||
a-34
|
||||
select 'a' union select concat('a', -0);
|
||||
a
|
||||
a
|
||||
a0
|
||||
select 'a' union select concat('a', -0.0);
|
||||
a
|
||||
a
|
||||
a0.0
|
||||
select 'a' union select concat('a', -0.0000);
|
||||
a
|
||||
a
|
||||
a0.0000
|
||||
select concat((select x from (select 'a' as x) as t1 ),
|
||||
(select y from (select 'b' as y) as t2 )) from (select 1 union select 2 )
|
||||
as t3;
|
||||
concat((select x from (select 'a' as x) as t1 ),
|
||||
(select y from (select 'b' as y) as t2 ))
|
||||
ab
|
||||
ab
|
||||
create table t1(f1 varchar(6)) charset=utf8;
|
||||
insert into t1 values ("123456");
|
||||
select concat(f1, 2) a from t1 union select 'x' a from t1;
|
||||
a
|
||||
1234562
|
||||
x
|
||||
drop table t1;
|
@ -1,97 +0,0 @@
|
||||
drop table if exists t1;
|
||||
select length(encrypt('foo', 'ff')) <> 0;
|
||||
length(encrypt('foo', 'ff')) <> 0
|
||||
1
|
||||
create table t1 (name varchar(50), pw varchar(64));
|
||||
insert into t1 values ('tom', password('my_pass'));
|
||||
set @pass='my_pass';
|
||||
select name from t1 where name='tom' and pw=password(@pass);
|
||||
name
|
||||
tom
|
||||
select name from t1 where name='tom' and pw=password(@undefined);
|
||||
name
|
||||
drop table t1;
|
||||
select password('abc');
|
||||
password('abc')
|
||||
*0D3CED9BEC10A777AEC23CCC353A8C08A633045E
|
||||
select password('');
|
||||
password('')
|
||||
|
||||
select old_password('abc');
|
||||
old_password('abc')
|
||||
7cd2b5942be28759
|
||||
select old_password('');
|
||||
old_password('')
|
||||
|
||||
select password('gabbagabbahey');
|
||||
password('gabbagabbahey')
|
||||
*B0F99D2963660DD7E16B751EC9EE2F17B6A68FA6
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
select length(password('1'));
|
||||
length(password('1'))
|
||||
41
|
||||
select length(encrypt('test'));
|
||||
length(encrypt('test'))
|
||||
13
|
||||
select encrypt('test','aa');
|
||||
encrypt('test','aa')
|
||||
aaqPiZY5xR5l.
|
||||
select old_password(NULL);
|
||||
old_password(NULL)
|
||||
NULL
|
||||
select password(NULL);
|
||||
password(NULL)
|
||||
NULL
|
||||
set global old_passwords=on;
|
||||
select password('');
|
||||
password('')
|
||||
|
||||
select old_password('');
|
||||
old_password('')
|
||||
|
||||
select password('idkfa');
|
||||
password('idkfa')
|
||||
*B669C9DAC3AA6F2254B03CDEF8DFDD6B2D1054BA
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
set old_passwords=on;
|
||||
select password('idkfa');
|
||||
password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
set global old_passwords=off;
|
||||
select password('idkfa');
|
||||
password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
set old_passwords=off;
|
||||
select password('idkfa ');
|
||||
password('idkfa ')
|
||||
*2DC31D90647B4C1ABC9231563D2236E96C9A2DB2
|
||||
select password('idkfa');
|
||||
password('idkfa')
|
||||
*B669C9DAC3AA6F2254B03CDEF8DFDD6B2D1054BA
|
||||
select password(' idkfa');
|
||||
password(' idkfa')
|
||||
*12B099E56BB7FE8D43C78FD834A9D1D11178D045
|
||||
select old_password('idkfa');
|
||||
old_password('idkfa')
|
||||
5c078dc54ca0fcca
|
||||
select old_password(' i d k f a ');
|
||||
old_password(' i d k f a ')
|
||||
5c078dc54ca0fcca
|
||||
explain extended select password('idkfa '), old_password('idkfa');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select password('idkfa ') AS `password('idkfa ')`,old_password('idkfa') AS `old_password('idkfa')`
|
||||
select encrypt('1234','_.');
|
||||
encrypt('1234','_.')
|
||||
#
|
@ -1,87 +0,0 @@
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1 (
|
||||
visitor_id int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
group_id int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
hits int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
sessions int(10) unsigned DEFAULT '0' NOT NULL,
|
||||
ts timestamp,
|
||||
PRIMARY KEY (visitor_id,group_id)
|
||||
)/*! engine=MyISAM */;
|
||||
INSERT INTO t1 VALUES (465931136,7,2,2,20000318160952);
|
||||
INSERT INTO t1 VALUES (173865424,2,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,8,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,39,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,7,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,3,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,6,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,60,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (173865424,1502,2,2,20000318233615);
|
||||
INSERT INTO t1 VALUES (48985536,2,2,2,20000319013932);
|
||||
INSERT INTO t1 VALUES (48985536,8,2,2,20000319013932);
|
||||
INSERT INTO t1 VALUES (48985536,39,2,2,20000319013932);
|
||||
INSERT INTO t1 VALUES (48985536,7,2,2,20000319013932);
|
||||
INSERT INTO t1 VALUES (465931136,3,2,2,20000318160951);
|
||||
INSERT INTO t1 VALUES (465931136,119,1,1,20000318160953);
|
||||
INSERT INTO t1 VALUES (465931136,2,1,1,20000318160950);
|
||||
INSERT INTO t1 VALUES (465931136,8,1,1,20000318160950);
|
||||
INSERT INTO t1 VALUES (465931136,39,1,1,20000318160950);
|
||||
INSERT INTO t1 VALUES (1092858576,14,1,1,20000319013445);
|
||||
INSERT INTO t1 VALUES (357917728,3,2,2,20000319145026);
|
||||
INSERT INTO t1 VALUES (357917728,7,2,2,20000319145027);
|
||||
select visitor_id,max(ts) as mts from t1 group by visitor_id
|
||||
having mts < DATE_SUB(NOW(),INTERVAL 3 MONTH);
|
||||
visitor_id mts
|
||||
48985536 2000-03-19 01:39:32
|
||||
173865424 2000-03-18 23:36:15
|
||||
357917728 2000-03-19 14:50:27
|
||||
465931136 2000-03-18 16:09:53
|
||||
1092858576 2000-03-19 01:34:45
|
||||
select visitor_id,max(ts) as mts from t1 group by visitor_id
|
||||
having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW();
|
||||
visitor_id mts
|
||||
48985536 2000-03-19 01:39:32
|
||||
173865424 2000-03-18 23:36:15
|
||||
357917728 2000-03-19 14:50:27
|
||||
465931136 2000-03-18 16:09:53
|
||||
1092858576 2000-03-19 01:34:45
|
||||
drop table t1;
|
||||
set sql_mode='traditional';
|
||||
create table t1 (d date);
|
||||
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
|
||||
ERROR 22008: Datetime function: datetime field overflow
|
||||
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
|
||||
ERROR 22008: Datetime function: datetime field overflow
|
||||
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
|
||||
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
|
||||
set sql_mode='';
|
||||
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
|
||||
Warnings:
|
||||
Warning 1441 Datetime function: datetime field overflow
|
||||
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
|
||||
Warnings:
|
||||
Warning 1441 Datetime function: datetime field overflow
|
||||
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
|
||||
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
|
||||
select * from t1;
|
||||
d
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
drop table t1;
|
||||
End of 4.1 tests
|
||||
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 DAY;
|
||||
CAST('2006-09-26' AS DATE) + INTERVAL 1 DAY
|
||||
2006-09-27
|
||||
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 MONTH;
|
||||
CAST('2006-09-26' AS DATE) + INTERVAL 1 MONTH
|
||||
2006-10-26
|
||||
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR;
|
||||
CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR
|
||||
2007-09-26
|
||||
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK;
|
||||
CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK
|
||||
2006-10-03
|
||||
End of 5.0 tests
|
@ -1,23 +0,0 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
|
||||
insert into t1 values ('','',0,0.0);
|
||||
select default(str), default(strnull), default(intg), default(rel) from t1;
|
||||
default(str) default(strnull) default(intg) default(rel)
|
||||
def NULL 10 3.14
|
||||
explain extended select default(str), default(strnull), default(intg), default(rel) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00
|
||||
Warnings:
|
||||
Note 1003 select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from `test`.`t1`
|
||||
select * from t1 where str <> default(str);
|
||||
str strnull intg rel
|
||||
0 0
|
||||
explain select * from t1 where str <> default(str);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (id int(11), s varchar(20));
|
||||
INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three');
|
||||
SELECT s, 32 AS mi FROM t1 GROUP BY s HAVING DEFAULT(mi) IS NULL;
|
||||
ERROR HY000: Field 'mi' doesn't have a default value
|
||||
DROP TABLE t1;
|
@ -1,44 +0,0 @@
|
||||
drop table if exists t1,t2;
|
||||
select 0<=>0,0.0<=>0.0,0E0=0E0,"A"<=>"A",NULL<=>NULL;
|
||||
0<=>0 0.0<=>0.0 0E0=0E0 "A"<=>"A" NULL<=>NULL
|
||||
1 1 1 1 1
|
||||
select 1<=>0,0<=>NULL,NULL<=>0;
|
||||
1<=>0 0<=>NULL NULL<=>0
|
||||
0 0 0
|
||||
select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
|
||||
1.0<=>0.0 0.0<=>NULL NULL<=>0.0
|
||||
0 0 0
|
||||
select "A"<=>"B","A"<=>NULL,NULL<=>"A";
|
||||
"A"<=>"B" "A"<=>NULL NULL<=>"A"
|
||||
0 0 0
|
||||
select 0<=>0.0, 0.0<=>0E0, 0E0<=>"0", 10.0<=>1E1, 10<=>10.0, 10<=>1E1;
|
||||
0<=>0.0 0.0<=>0E0 0E0<=>"0" 10.0<=>1E1 10<=>10.0 10<=>1E1
|
||||
1 1 1 1 1 1
|
||||
select 1.0<=>0E1,10<=>NULL,NULL<=>0.0, NULL<=>0E0;
|
||||
1.0<=>0E1 10<=>NULL NULL<=>0.0 NULL<=>0E0
|
||||
0 0 0 0
|
||||
create table t1 (id int, value int);
|
||||
create table t2 (id int, value int);
|
||||
insert into t1 values (1,null);
|
||||
insert into t2 values (1,null);
|
||||
select t1.*, t2.*, t1.value<=>t2.value from t1, t2 where t1.id=t2.id and t1.id=1;
|
||||
id value id value t1.value<=>t2.value
|
||||
1 NULL 1 NULL 1
|
||||
select * from t1 where id <=>id;
|
||||
id value
|
||||
1 NULL
|
||||
select * from t1 where value <=> value;
|
||||
id value
|
||||
1 NULL
|
||||
select * from t1 where id <=> value or value<=>id;
|
||||
id value
|
||||
drop table t1,t2;
|
||||
create table t1 (a bigint unsigned);
|
||||
insert into t1 values (4828532208463511553);
|
||||
select * from t1 where a = '4828532208463511553';
|
||||
a
|
||||
4828532208463511553
|
||||
select * from t1 where a in ('4828532208463511553');
|
||||
a
|
||||
4828532208463511553
|
||||
drop table t1;
|
@ -1,744 +0,0 @@
|
||||
drop table if exists t1, t2;
|
||||
create table t1 (grp int, a bigint unsigned, c char(10) not null, d char(10) not null);
|
||||
insert into t1 values (1,1,"a","a");
|
||||
insert into t1 values (2,2,"b","a");
|
||||
insert into t1 values (2,3,"c","b");
|
||||
insert into t1 values (3,4,"E","a");
|
||||
insert into t1 values (3,5,"C","b");
|
||||
insert into t1 values (3,6,"D","b");
|
||||
insert into t1 values (3,7,"d","d");
|
||||
insert into t1 values (3,8,"d","d");
|
||||
insert into t1 values (3,9,"D","c");
|
||||
select grp,group_concat(c) from t1 group by grp;
|
||||
grp group_concat(c)
|
||||
1 a
|
||||
2 b,c
|
||||
3 E,C,D,d,d,D
|
||||
explain extended select grp,group_concat(c) from t1 group by grp;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 100.00 Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`grp` AS `grp`,group_concat(`test`.`t1`.`c` separator ',') AS `group_concat(c)` from `test`.`t1` group by `test`.`t1`.`grp`
|
||||
select grp,group_concat(a,c) from t1 group by grp;
|
||||
grp group_concat(a,c)
|
||||
1 1a
|
||||
2 2b,3c
|
||||
3 4E,5C,6D,7d,8d,9D
|
||||
select grp,group_concat("(",a,":",c,")") from t1 group by grp;
|
||||
grp group_concat("(",a,":",c,")")
|
||||
1 (1:a)
|
||||
2 (2:b),(3:c)
|
||||
3 (4:E),(5:C),(6:D),(7:d),(8:d),(9:D)
|
||||
select grp,group_concat(c separator ",") from t1 group by grp;
|
||||
grp group_concat(c separator ",")
|
||||
1 a
|
||||
2 b,c
|
||||
3 E,C,D,d,d,D
|
||||
select grp,group_concat(c separator "---->") from t1 group by grp;
|
||||
grp group_concat(c separator "---->")
|
||||
1 a
|
||||
2 b---->c
|
||||
3 E---->C---->D---->d---->d---->D
|
||||
select grp,group_concat(c order by c) from t1 group by grp;
|
||||
grp group_concat(c order by c)
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,d,d,D,E
|
||||
select grp,group_concat(c order by c desc) from t1 group by grp;
|
||||
grp group_concat(c order by c desc)
|
||||
1 a
|
||||
2 c,b
|
||||
3 E,D,d,d,D,C
|
||||
select grp,group_concat(d order by a) from t1 group by grp;
|
||||
grp group_concat(d order by a)
|
||||
1 a
|
||||
2 a,b
|
||||
3 a,b,b,d,d,c
|
||||
select grp,group_concat(d order by a desc) from t1 group by grp;
|
||||
grp group_concat(d order by a desc)
|
||||
1 a
|
||||
2 b,a
|
||||
3 c,d,d,b,b,a
|
||||
select grp,group_concat(a order by a,d+c-ascii(c)-a) from t1 group by grp;
|
||||
grp group_concat(a order by a,d+c-ascii(c)-a)
|
||||
1 1
|
||||
2 2,3
|
||||
3 4,5,6,7,8,9
|
||||
select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp;
|
||||
grp group_concat(a order by d+c-ascii(c),a)
|
||||
1 1
|
||||
2 3,2
|
||||
3 7,8,4,6,9,5
|
||||
select grp,group_concat(c order by 1) from t1 group by grp;
|
||||
grp group_concat(c order by 1)
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,d,d,D,E
|
||||
select grp,group_concat(distinct c order by c) from t1 group by grp;
|
||||
grp group_concat(distinct c order by c)
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,E
|
||||
select grp,group_concat(distinct c order by c desc) from t1 group by grp;
|
||||
grp group_concat(distinct c order by c desc)
|
||||
1 a
|
||||
2 c,b
|
||||
3 E,D,C
|
||||
explain extended select grp,group_concat(distinct c order by c desc) from t1 group by grp;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 100.00 Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`grp` AS `grp`,group_concat(distinct `test`.`t1`.`c` order by `test`.`t1`.`c` DESC separator ',') AS `group_concat(distinct c order by c desc)` from `test`.`t1` group by `test`.`t1`.`grp`
|
||||
select grp,group_concat(c order by c separator ",") from t1 group by grp;
|
||||
grp group_concat(c order by c separator ",")
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,d,d,D,E
|
||||
select grp,group_concat(c order by c desc separator ",") from t1 group by grp;
|
||||
grp group_concat(c order by c desc separator ",")
|
||||
1 a
|
||||
2 c,b
|
||||
3 E,D,d,d,D,C
|
||||
select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
|
||||
grp group_concat(distinct c order by c separator ",")
|
||||
1 a
|
||||
2 b,c
|
||||
3 C,D,E
|
||||
explain extended select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 100.00 Using filesort
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`grp` AS `grp`,group_concat(distinct `test`.`t1`.`c` order by `test`.`t1`.`c` ASC separator ',') AS `group_concat(distinct c order by c separator ",")` from `test`.`t1` group by `test`.`t1`.`grp`
|
||||
select grp,group_concat(distinct c order by c desc separator ",") from t1 group by grp;
|
||||
grp group_concat(distinct c order by c desc separator ",")
|
||||
1 a
|
||||
2 c,b
|
||||
3 E,D,C
|
||||
select grp,group_concat(c order by grp desc) from t1 group by grp order by grp;
|
||||
grp group_concat(c order by grp desc)
|
||||
1 a
|
||||
2 c,b
|
||||
3 D,d,d,D,C,E
|
||||
select grp, group_concat(a separator "")+0 from t1 group by grp;
|
||||
grp group_concat(a separator "")+0
|
||||
1 1
|
||||
2 23
|
||||
3 456789
|
||||
select grp, group_concat(a separator "")+0.0 from t1 group by grp;
|
||||
grp group_concat(a separator "")+0.0
|
||||
1 1.0
|
||||
2 23.0
|
||||
3 456789.0
|
||||
select grp, ROUND(group_concat(a separator "")) from t1 group by grp;
|
||||
grp ROUND(group_concat(a separator ""))
|
||||
1 1
|
||||
2 23
|
||||
3 456789
|
||||
drop table t1;
|
||||
create table t1 (grp int, c char(10));
|
||||
insert into t1 values (1,NULL),(2,"b"),(2,NULL),(3,"E"),(3,NULL),(3,"D"),(3,NULL),(3,NULL),(3,"D"),(4,""),(5,NULL);
|
||||
select grp,group_concat(c order by c) from t1 group by grp;
|
||||
grp group_concat(c order by c)
|
||||
1 NULL
|
||||
2 b
|
||||
3 D,D,E
|
||||
4
|
||||
5 NULL
|
||||
set group_concat_max_len = 4;
|
||||
select grp,group_concat(c) from t1 group by grp;
|
||||
grp group_concat(c)
|
||||
1 NULL
|
||||
2 b
|
||||
3 E,D,
|
||||
4
|
||||
5 NULL
|
||||
Warnings:
|
||||
Warning 1260 Row 4 was cut by GROUP_CONCAT()
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 1260 Row 4 was cut by GROUP_CONCAT()
|
||||
set group_concat_max_len = 1024;
|
||||
select group_concat(sum(c)) from t1 group by grp;
|
||||
ERROR HY000: Invalid use of group function
|
||||
select grp,group_concat(c order by 2) from t1 group by grp;
|
||||
ERROR 42S22: Unknown column '2' in 'order clause'
|
||||
drop table t1;
|
||||
create table t1 ( URL_ID int(11), URL varchar(80));
|
||||
create table t2 ( REQ_ID int(11), URL_ID int(11));
|
||||
insert into t1 values (4,'www.host.com'), (5,'www.google.com'),(5,'www.help.com');
|
||||
insert into t2 values (1,4), (5,4), (5,5);
|
||||
select REQ_ID, Group_Concat(URL) as URL from t1, t2 where
|
||||
t2.URL_ID = t1.URL_ID group by REQ_ID;
|
||||
REQ_ID URL
|
||||
1 X
|
||||
5 X,X,X
|
||||
select REQ_ID, Group_Concat(URL) as URL, Min(t1.URL_ID) urll,
|
||||
Max(t1.URL_ID) urlg from t1, t2 where t2.URL_ID = t1.URL_ID group by REQ_ID;
|
||||
REQ_ID URL urll urlg
|
||||
1 X 4 4
|
||||
5 X,X,X 4 5
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table t1 (id int, name varchar(16));
|
||||
insert into t1 values (1,'longername'),(1,'evenlongername');
|
||||
select ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'without distinct: how it should be' from t1;
|
||||
without distinct: how it should be
|
||||
1:longername,1:evenlongername
|
||||
select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with distinct: cutoff at length of shortname' from t1;
|
||||
with distinct: cutoff at length of shortname
|
||||
1:longername,1:evenlongername
|
||||
drop table t1;
|
||||
create table t1(id int);
|
||||
create table t2(id int);
|
||||
insert into t1 values(0),(1);
|
||||
select group_concat(t1.id) FROM t1,t2;
|
||||
group_concat(t1.id)
|
||||
NULL
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table t1 (bar varchar(32));
|
||||
insert into t1 values('test1'),('test2');
|
||||
select group_concat(bar order by concat(bar,bar)) from t1;
|
||||
group_concat(bar order by concat(bar,bar))
|
||||
test1,test2
|
||||
select group_concat(bar order by concat(bar,bar) desc) from t1;
|
||||
group_concat(bar order by concat(bar,bar) desc)
|
||||
test2,test1
|
||||
select bar from t1 having group_concat(bar)='';
|
||||
bar
|
||||
select bar from t1 having instr(group_concat(bar), "test") > 0;
|
||||
bar
|
||||
test1
|
||||
select bar from t1 having instr(group_concat(bar order by concat(bar,bar) desc), "test2,test1") > 0;
|
||||
bar
|
||||
test1
|
||||
drop table t1;
|
||||
create table t1 (a int, a1 varchar(10));
|
||||
create table t2 (a0 int);
|
||||
insert into t1 values (0,"a"),(0,"b"),(1,"c");
|
||||
insert into t2 values (1),(2),(3);
|
||||
select group_concat(a1 order by (t1.a IN (select a0 from t2))) from t1;
|
||||
group_concat(a1 order by (t1.a IN (select a0 from t2)))
|
||||
b,a,c
|
||||
select group_concat(a1 order by (t1.a)) from t1;
|
||||
group_concat(a1 order by (t1.a))
|
||||
b,a,c
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (id1 tinyint(4) NOT NULL, id2 tinyint(4) NOT NULL);
|
||||
INSERT INTO t1 VALUES (1, 1),(1, 2),(1, 3),(1, 4),(1, 5),(2, 1),(2, 2),(2, 3);
|
||||
CREATE TABLE t2 (id1 tinyint(4) NOT NULL);
|
||||
INSERT INTO t2 VALUES (1),(2),(3),(4),(5);
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2 ORDER BY t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 AND t1.id1=1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 1,2,3,4,5
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2 ORDER BY t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 1,2,3,4,5
|
||||
2 1,2,3
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2 ORDER BY t1.id2 DESC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 5,4,3,2,1
|
||||
2 3,2,1
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2 ORDER BY 6-t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 5,4,3,2,1
|
||||
2 3,2,1
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2,6-t1.id2 ORDER BY 6-t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 51,42,33,24,15
|
||||
2 33,24,15
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2,6-t1.id2 ORDER BY 6-t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 51,42,33,24,15
|
||||
2 33,24,15
|
||||
SELECT t1.id1, GROUP_CONCAT(t1.id2,"/",6-t1.id2 ORDER BY 1+0,6-t1.id2,t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 GROUP BY t1.id1;
|
||||
id1 concat_id
|
||||
1 5/1,4/2,3/3,2/4,1/5
|
||||
2 3/3,2/4,1/5
|
||||
drop table t1,t2;
|
||||
create table t1 (s1 char(10), s2 int not null);
|
||||
insert into t1 values ('a',2),('b',2),('c',1),('a',3),('b',4),('c',4);
|
||||
select distinct s1 from t1 order by s2,s1;
|
||||
s1
|
||||
c
|
||||
a
|
||||
b
|
||||
select group_concat(distinct s1) from t1;
|
||||
group_concat(distinct s1)
|
||||
a,b,c
|
||||
select group_concat(distinct s1 order by s2) from t1 where s2 < 4;
|
||||
group_concat(distinct s1 order by s2)
|
||||
c,b,a
|
||||
select group_concat(distinct s1 order by s2) from t1;
|
||||
group_concat(distinct s1 order by s2)
|
||||
c,b,a
|
||||
drop table t1;
|
||||
create table t1 (a int, c int);
|
||||
insert into t1 values (1, 2), (2, 3), (2, 4), (3, 5);
|
||||
create table t2 (a int, c int);
|
||||
insert into t2 values (1, 5), (2, 4), (3, 3), (3,3);
|
||||
select group_concat(c) from t1;
|
||||
group_concat(c)
|
||||
2,3,4,5
|
||||
select group_concat(c order by (select c from t2 where t2.a=t1.a limit 1)) as grp from t1;
|
||||
grp
|
||||
5,4,3,2
|
||||
select group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a)) as grp from t1;
|
||||
grp
|
||||
5,4,3,2
|
||||
select group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a) desc) as grp from t1;
|
||||
grp
|
||||
2,4,3,5
|
||||
select t1.a, group_concat(c order by (select c from t2 where t2.a=t1.a limit 1)) as grp from t1 group by 1;
|
||||
a grp
|
||||
1 2
|
||||
2 4,3
|
||||
3 5
|
||||
select t1.a, group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a)) as grp from t1 group by 1;
|
||||
a grp
|
||||
1 2
|
||||
2 4,3
|
||||
3 5
|
||||
select t1.a, group_concat(c order by (select mid(group_concat(c order by a),1,5) from t2 where t2.a=t1.a) desc) as grp from t1 group by 1;
|
||||
a grp
|
||||
1 2
|
||||
2 4,3
|
||||
3 5
|
||||
select group_concat(c order by (select concat(5-t1.c,group_concat(c order by a)) from t2 where t2.a=t1.a)) as grp from t1;
|
||||
grp
|
||||
5,4,3,2
|
||||
select group_concat(c order by (select concat(t1.c,group_concat(c)) from t2 where a=t1.a)) as grp from t1;
|
||||
grp
|
||||
2,3,4,5
|
||||
select a,c,(select group_concat(c order by a) from t2 where a=t1.a) as grp from t1 order by grp;
|
||||
a c grp
|
||||
3 5 3,3
|
||||
2 3 4
|
||||
2 4 4
|
||||
1 2 5
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 ( a int );
|
||||
CREATE TABLE t2 ( a int );
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
INSERT INTO t2 VALUES (1), (2);
|
||||
SELECT GROUP_CONCAT(t1.a*t2.a ORDER BY t2.a) FROM t1, t2 GROUP BY t1.a;
|
||||
GROUP_CONCAT(t1.a*t2.a ORDER BY t2.a)
|
||||
1,2
|
||||
2,4
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 (a char(4));
|
||||
INSERT INTO t1 VALUES ('John'), ('Anna'), ('Bill');
|
||||
SELECT GROUP_CONCAT(a SEPARATOR '||') AS names FROM t1
|
||||
HAVING names LIKE '%An%';
|
||||
names
|
||||
John||Anna||Bill
|
||||
SELECT GROUP_CONCAT(a SEPARATOR '###') AS names FROM t1
|
||||
HAVING LEFT(names, 1) ='J';
|
||||
names
|
||||
John###Anna###Bill
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 ( a int, b TEXT );
|
||||
INSERT INTO t1 VALUES (1,'First Row'), (2,'Second Row');
|
||||
SELECT GROUP_CONCAT(b ORDER BY b) FROM t1 GROUP BY a;
|
||||
GROUP_CONCAT(b ORDER BY b)
|
||||
First Row
|
||||
Second Row
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (A_ID INT NOT NULL,A_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID));
|
||||
INSERT INTO t1 VALUES (1,'ABC'), (2,'EFG'), (3,'HIJ');
|
||||
CREATE TABLE t2 (A_ID INT NOT NULL,B_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID,B_DESC));
|
||||
INSERT INTO t2 VALUES (1,'A'),(1,'B'),(3,'F');
|
||||
SELECT t1.A_ID, GROUP_CONCAT(t2.B_DESC) AS B_DESC FROM t1 LEFT JOIN t2 ON t1.A_ID=t2.A_ID GROUP BY t1.A_ID ORDER BY t1.A_DESC;
|
||||
A_ID B_DESC
|
||||
1 A,B
|
||||
2 NULL
|
||||
3 F
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
create table t1 (a int, b text);
|
||||
insert into t1 values (1, 'bb'), (1, 'ccc'), (1, 'a'), (1, 'bb'), (1, 'ccc');
|
||||
insert into t1 values (2, 'BB'), (2, 'CCC'), (2, 'A'), (2, 'BB'), (2, 'CCC');
|
||||
select group_concat(b) from t1 group by a;
|
||||
group_concat(b)
|
||||
bb,ccc,a,bb,ccc
|
||||
BB,CCC,A,BB,CCC
|
||||
select group_concat(distinct b) from t1 group by a;
|
||||
group_concat(distinct b)
|
||||
bb,ccc,a
|
||||
BB,CCC,A
|
||||
select group_concat(b order by b) from t1 group by a;
|
||||
group_concat(b order by b)
|
||||
a,bb,bb,ccc,ccc
|
||||
A,BB,BB,CCC,CCC
|
||||
select group_concat(distinct b order by b) from t1 group by a;
|
||||
group_concat(distinct b order by b)
|
||||
a,bb,ccc
|
||||
A,BB,CCC
|
||||
set local group_concat_max_len=4;
|
||||
select group_concat(b) from t1 group by a;
|
||||
group_concat(b)
|
||||
bb,c
|
||||
BB,C
|
||||
Warnings:
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 4 was cut by GROUP_CONCAT()
|
||||
select group_concat(distinct b) from t1 group by a;
|
||||
group_concat(distinct b)
|
||||
bb,c
|
||||
BB,C
|
||||
Warnings:
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 4 was cut by GROUP_CONCAT()
|
||||
select group_concat(b order by b) from t1 group by a;
|
||||
group_concat(b order by b)
|
||||
a,bb
|
||||
A,BB
|
||||
Warnings:
|
||||
Warning 1260 Row 3 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 6 was cut by GROUP_CONCAT()
|
||||
select group_concat(distinct b order by b) from t1 group by a;
|
||||
group_concat(distinct b order by b)
|
||||
a,bb
|
||||
A,BB
|
||||
Warnings:
|
||||
Warning 1260 Row 3 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 6 was cut by GROUP_CONCAT()
|
||||
insert into t1 values (1, concat(repeat('1', 300), '2')),
|
||||
(1, concat(repeat('1', 300), '2')), (1, concat(repeat('0', 300), '1')),
|
||||
(2, concat(repeat('1', 300), '2')), (2, concat(repeat('1', 300), '2')),
|
||||
(2, concat(repeat('0', 300), '1'));
|
||||
set local group_concat_max_len=1024;
|
||||
select group_concat(b) from t1 group by a;
|
||||
group_concat(b)
|
||||
bb,ccc,a,bb,ccc,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
|
||||
BB,CCC,A,BB,CCC,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
|
||||
select group_concat(distinct b) from t1 group by a;
|
||||
group_concat(distinct b)
|
||||
bb,ccc,a,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
|
||||
BB,CCC,A,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
|
||||
select group_concat(b order by b) from t1 group by a;
|
||||
group_concat(b order by b)
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,a,bb,bb,ccc,ccc
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,A,BB,BB,CCC,CCC
|
||||
select group_concat(distinct b order by b) from t1 group by a;
|
||||
group_concat(distinct b order by b)
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,a,bb,ccc
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,A,BB,CCC
|
||||
set local group_concat_max_len=400;
|
||||
select group_concat(b) from t1 group by a;
|
||||
group_concat(b)
|
||||
bb,ccc,a,bb,ccc,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
BB,CCC,A,BB,CCC,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,1111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
Warnings:
|
||||
Warning 1260 Row 7 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 14 was cut by GROUP_CONCAT()
|
||||
select group_concat(distinct b) from t1 group by a;
|
||||
group_concat(distinct b)
|
||||
bb,ccc,a,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
BB,CCC,A,1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112,00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
Warnings:
|
||||
Warning 1260 Row 5 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 10 was cut by GROUP_CONCAT()
|
||||
select group_concat(b order by b) from t1 group by a;
|
||||
group_concat(b order by b)
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
Warnings:
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 4 was cut by GROUP_CONCAT()
|
||||
select group_concat(distinct b order by b) from t1 group by a;
|
||||
group_concat(distinct b order by b)
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001,11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
||||
Warnings:
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 4 was cut by GROUP_CONCAT()
|
||||
drop table t1;
|
||||
create table t1 (a varchar(255) character set cp1250 collate cp1250_general_ci,
|
||||
b varchar(255) character set koi8r);
|
||||
insert into t1 values ('xxx','yyy');
|
||||
select collation(a) from t1;
|
||||
collation(a)
|
||||
cp1250_general_ci
|
||||
select collation(group_concat(a)) from t1;
|
||||
collation(group_concat(a))
|
||||
cp1250_general_ci
|
||||
create table t2 select group_concat(a) as a from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` varchar(400) CHARACTER SET cp1250 DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select collation(group_concat(a,_koi8r'test')) from t1;
|
||||
collation(group_concat(a,_koi8r'test'))
|
||||
cp1250_general_ci
|
||||
select collation(group_concat(a,_koi8r 0xC1C2)) from t1;
|
||||
ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,COERCIBLE) for operation 'group_concat'
|
||||
select collation(group_concat(a,b)) from t1;
|
||||
ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,IMPLICIT) for operation 'group_concat'
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp850);
|
||||
INSERT INTO t1 VALUES ('À');
|
||||
SELECT a FROM t1;
|
||||
a
|
||||
À
|
||||
SELECT GROUP_CONCAT(a) FROM t1;
|
||||
GROUP_CONCAT(a)
|
||||
À
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id int);
|
||||
SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL;
|
||||
gc
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
create table t2 (a int, b int);
|
||||
insert into t2 values (1,1), (2,2);
|
||||
select b x, (select group_concat(x) from t2) from t2;
|
||||
x (select group_concat(x) from t2)
|
||||
1 1,1
|
||||
2 2,2
|
||||
drop table t2;
|
||||
create table t1 (d int not null auto_increment,primary key(d), a int, b int, c int);
|
||||
insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3);
|
||||
select d,a,b from t1 order by a;
|
||||
d a b
|
||||
1 1 3
|
||||
2 1 4
|
||||
3 1 2
|
||||
5 1 1
|
||||
6 1 2
|
||||
4 2 7
|
||||
7 2 3
|
||||
8 2 3
|
||||
explain select a, group_concat(b) from t1 group by a with rollup;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using filesort
|
||||
select a, group_concat(b) from t1 group by a with rollup;
|
||||
a group_concat(b)
|
||||
1 3,4,2,1,2
|
||||
2 7,3,3
|
||||
NULL 3,4,2,1,2,7,3,3
|
||||
select a, group_concat(distinct b) from t1 group by a with rollup;
|
||||
a group_concat(distinct b)
|
||||
1 3,4,2,1
|
||||
2 7,3
|
||||
NULL 3,4,2,1,7
|
||||
select a, group_concat(b order by b) from t1 group by a with rollup;
|
||||
a group_concat(b order by b)
|
||||
1 1,2,2,3,4
|
||||
2 3,3,7
|
||||
NULL 1,2,2,3,3,3,4,7
|
||||
select a, group_concat(distinct b order by b) from t1 group by a with rollup;
|
||||
a group_concat(distinct b order by b)
|
||||
1 1,2,3,4
|
||||
2 3,7
|
||||
NULL 1,2,3,4,7
|
||||
drop table t1;
|
||||
create table t1 (a char(3), b char(20), primary key (a, b));
|
||||
insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English');
|
||||
select group_concat(a) from t1 group by b;
|
||||
group_concat(a)
|
||||
ABW
|
||||
ABW
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
aID smallint(5) unsigned NOT NULL auto_increment,
|
||||
sometitle varchar(255) NOT NULL default '',
|
||||
bID smallint(5) unsigned NOT NULL,
|
||||
PRIMARY KEY (aID),
|
||||
UNIQUE KEY sometitle (sometitle)
|
||||
);
|
||||
INSERT INTO t1 SET sometitle = 'title1', bID = 1;
|
||||
INSERT INTO t1 SET sometitle = 'title2', bID = 1;
|
||||
CREATE TABLE t2 (
|
||||
bID smallint(5) unsigned NOT NULL auto_increment,
|
||||
somename varchar(255) NOT NULL default '',
|
||||
PRIMARY KEY (bID),
|
||||
UNIQUE KEY somename (somename)
|
||||
);
|
||||
INSERT INTO t2 SET somename = 'test';
|
||||
SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
FROM t1 JOIN t2 ON t1.bID = t2.bID;
|
||||
COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
2 test
|
||||
INSERT INTO t2 SET somename = 'test2';
|
||||
SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
FROM t1 JOIN t2 ON t1.bID = t2.bID;
|
||||
COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
2 test
|
||||
DELETE FROM t2 WHERE somename = 'test2';
|
||||
SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
FROM t1 JOIN t2 ON t1.bID = t2.bID;
|
||||
COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
|
||||
2 test
|
||||
DROP TABLE t1,t2;
|
||||
select * from (select group_concat('c') from DUAL) t;
|
||||
group_concat('c')
|
||||
c
|
||||
create table t1 ( a int not null default 0);
|
||||
select * from (select group_concat(a) from t1) t2;
|
||||
group_concat(a)
|
||||
NULL
|
||||
select group_concat('x') UNION ALL select 1;
|
||||
group_concat('x')
|
||||
x
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (id int, a varchar(9));
|
||||
INSERT INTO t1 VALUES
|
||||
(2, ''), (1, ''), (2, 'x'), (1, 'y'), (3, 'z'), (3, '');
|
||||
SELECT GROUP_CONCAT(a) FROM t1;
|
||||
GROUP_CONCAT(a)
|
||||
,,x,y,z,
|
||||
SELECT GROUP_CONCAT(a ORDER BY a) FROM t1;
|
||||
GROUP_CONCAT(a ORDER BY a)
|
||||
,,,x,y,z
|
||||
SELECT GROUP_CONCAT(a) FROM t1 GROUP BY id;
|
||||
GROUP_CONCAT(a)
|
||||
,y
|
||||
,x
|
||||
z,
|
||||
SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY id;
|
||||
GROUP_CONCAT(a ORDER BY a)
|
||||
,y
|
||||
,x
|
||||
,z
|
||||
DROP TABLE t1;
|
||||
create table t1(f1 int);
|
||||
insert into t1 values(1),(2),(3);
|
||||
select f1, group_concat(f1+1) from t1 group by f1 with rollup;
|
||||
f1 group_concat(f1+1)
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
NULL 2,3,4
|
||||
select count(distinct (f1+1)) from t1 group by f1 with rollup;
|
||||
count(distinct (f1+1))
|
||||
1
|
||||
1
|
||||
1
|
||||
3
|
||||
drop table t1;
|
||||
create table t1 (f1 int unsigned, f2 varchar(255));
|
||||
insert into t1 values (1,repeat('a',255)),(2,repeat('b',255));
|
||||
select f2,group_concat(f1) from t1 group by f2;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 t1 f2 f2 253 255 255 Y 0 0 8
|
||||
def group_concat(f1) 253 400 1 Y 0 0 8
|
||||
f2 group_concat(f1)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2
|
||||
drop table t1;
|
||||
set names latin1;
|
||||
create table t1 (a char, b char);
|
||||
insert into t1 values ('a', 'a'), ('a', 'b'), ('b', 'a'), ('b', 'b');
|
||||
create table t2 select group_concat(b) as a from t1 where a = 'a';
|
||||
create table t3 (select group_concat(a) as a from t1 where a = 'a') union
|
||||
(select group_concat(b) as a from t1 where a = 'b');
|
||||
select charset(a) from t2;
|
||||
charset(a)
|
||||
latin1
|
||||
select charset(a) from t3;
|
||||
charset(a)
|
||||
latin1
|
||||
latin1
|
||||
drop table t1, t2, t3;
|
||||
set names default;
|
||||
create table t1 (c1 varchar(10), c2 int);
|
||||
select charset(group_concat(c1 order by c2)) from t1;
|
||||
charset(group_concat(c1 order by c2))
|
||||
latin1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a));
|
||||
SET GROUP_CONCAT_MAX_LEN = 20000000;
|
||||
INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000));
|
||||
INSERT INTO t1 SELECT a + 1, b FROM t1;
|
||||
SELECT a, CHAR_LENGTH(b) FROM t1;
|
||||
a CHAR_LENGTH(b)
|
||||
1 120000
|
||||
2 120000
|
||||
SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1;
|
||||
CHAR_LENGTH( GROUP_CONCAT(b) )
|
||||
240001
|
||||
SET GROUP_CONCAT_MAX_LEN = 1024;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
INSERT INTO t1 VALUES (2,1), (1,2), (2,2), (1,3);
|
||||
SELECT GROUP_CONCAT(a), x
|
||||
FROM (SELECT a, GROUP_CONCAT(b) x FROM t1 GROUP BY a) AS s
|
||||
GROUP BY x;
|
||||
GROUP_CONCAT(a) x
|
||||
2 1,2
|
||||
1 2,3
|
||||
DROP TABLE t1;
|
||||
set names utf8;
|
||||
create table t1
|
||||
(
|
||||
x text character set utf8 not null,
|
||||
y integer not null
|
||||
);
|
||||
insert into t1 values (repeat('a', 1022), 0), (repeat(_utf8 0xc3b7, 4), 0);
|
||||
set group_concat_max_len= 1022 + 10;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1032 1031 1027 aaaaaaa,÷÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 9;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1031 1031 1027 aaaaaaa,÷÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 8;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1030 1029 1026 aaaaaaaa,÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 7;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1029 1029 1026 aaaaaaaa,÷÷÷ C3B7C3B7C3B7
|
||||
set group_concat_max_len= 1022 + 6;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1028 1027 1025 aaaaaaaaa,÷÷ 612CC3B7C3B7
|
||||
set group_concat_max_len= 1022 + 5;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1027 1027 1025 aaaaaaaaa,÷÷ 612CC3B7C3B7
|
||||
set group_concat_max_len= 1022 + 4;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1026 1025 1024 aaaaaaaaaa,÷ 6161612CC3B7
|
||||
set group_concat_max_len= 1022 + 3;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1025 1025 1024 aaaaaaaaaa,÷ 6161612CC3B7
|
||||
set group_concat_max_len= 1022 + 2;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1024 1023 1023 aaaaaaaaaaa, 61616161612C
|
||||
set group_concat_max_len= 1022 + 1;
|
||||
select @x:=group_concat(x) from t1 group by y;
|
||||
select @@group_concat_max_len, length(@x), char_length(@x), right(@x,12), right(HEX(@x),12);
|
||||
@@group_concat_max_len length(@x) char_length(@x) right(@x,12) right(HEX(@x),12)
|
||||
1023 1023 1023 aaaaaaaaaaa, 61616161612C
|
||||
drop table t1;
|
||||
set group_concat_max_len=1024;
|
||||
set names latin1;
|
||||
create table t1 (f1 int unsigned, f2 varchar(255));
|
||||
insert into t1 values (1,repeat('a',255)),(2,repeat('b',255));
|
||||
select f2,group_concat(f1) from t1 group by f2;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 t1 f2 f2 253 255 255 Y 0 0 8
|
||||
def group_concat(f1) 252 1024 1 Y 0 0 8
|
||||
f2 group_concat(f1)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2
|
||||
drop table t1;
|
File diff suppressed because it is too large
Load Diff
@ -1,130 +0,0 @@
|
||||
drop table if exists t1;
|
||||
select IF(0,"ERROR","this"),IF(1,"is","ERROR"),IF(NULL,"ERROR","a"),IF(1,2,3)|0,IF(1,2.0,3.0)+0 ;
|
||||
IF(0,"ERROR","this") IF(1,"is","ERROR") IF(NULL,"ERROR","a") IF(1,2,3)|0 IF(1,2.0,3.0)+0
|
||||
this is a 2 2.0
|
||||
CREATE TABLE t1 (st varchar(255) NOT NULL, u int(11) NOT NULL) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('a',1),('A',1),('aa',1),('AA',1),('a',1),('aaa',0),('BBB',0);
|
||||
select if(1,st,st) s from t1 order by s;
|
||||
s
|
||||
a
|
||||
A
|
||||
a
|
||||
aa
|
||||
AA
|
||||
aaa
|
||||
BBB
|
||||
select if(u=1,st,st) s from t1 order by s;
|
||||
s
|
||||
a
|
||||
A
|
||||
a
|
||||
aa
|
||||
AA
|
||||
aaa
|
||||
BBB
|
||||
select if(u=1,binary st,st) s from t1 order by s;
|
||||
s
|
||||
A
|
||||
AA
|
||||
BBB
|
||||
a
|
||||
a
|
||||
aa
|
||||
aaa
|
||||
select if(u=1,st,binary st) s from t1 where st like "%a%" order by s;
|
||||
s
|
||||
A
|
||||
AA
|
||||
a
|
||||
a
|
||||
aa
|
||||
aaa
|
||||
explain extended select if(u=1,st,binary st) s from t1 where st like "%a%" order by s;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00 Using where; Using filesort
|
||||
Warnings:
|
||||
Note 1003 select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like '%a%') order by if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary))
|
||||
select nullif(u, 1) from t1;
|
||||
nullif(u, 1)
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
0
|
||||
0
|
||||
explain extended select nullif(u, 1) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00
|
||||
Warnings:
|
||||
Note 1003 select nullif(`test`.`t1`.`u`,1) AS `nullif(u, 1)` from `test`.`t1`
|
||||
drop table t1;
|
||||
select nullif(1,'test');
|
||||
nullif(1,'test')
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'test'
|
||||
select NULLIF(NULL,NULL), NULLIF(NULL,1), NULLIF(NULL,1.0), NULLIF(NULL,"test");
|
||||
NULLIF(NULL,NULL) NULLIF(NULL,1) NULLIF(NULL,1.0) NULLIF(NULL,"test")
|
||||
NULL NULL NULL NULL
|
||||
select NULLIF(1,NULL), NULLIF(1.0, NULL), NULLIF("test", NULL);
|
||||
NULLIF(1,NULL) NULLIF(1.0, NULL) NULLIF("test", NULL)
|
||||
1 1.0 test
|
||||
create table t1 (num double(12,2));
|
||||
insert into t1 values (144.54);
|
||||
select sum(if(num is null,0.00,num)) from t1;
|
||||
sum(if(num is null,0.00,num))
|
||||
144.54
|
||||
drop table t1;
|
||||
create table t1 (x int, y int);
|
||||
insert into t1 values (0,6),(10,16),(20,26),(30,10),(40,46),(50,56);
|
||||
select min(if(y -x > 5,y,NULL)), max(if(y - x > 5,y,NULL)) from t1;
|
||||
min(if(y -x > 5,y,NULL)) max(if(y - x > 5,y,NULL))
|
||||
6 56
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert t1 values (1),(2);
|
||||
select if(1>2,a,avg(a)) from t1;
|
||||
if(1>2,a,avg(a))
|
||||
1.5000
|
||||
drop table t1;
|
||||
SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL;
|
||||
NULLIF(5,5) IS NULL NULLIF(5,5) IS NOT NULL
|
||||
1 0
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`date` int(10) default NULL,
|
||||
`text` varchar(32) NOT NULL
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3');
|
||||
SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC;
|
||||
id date_ord text
|
||||
1 05-03-2005 Day 1
|
||||
2 16-03-2005 Day 2
|
||||
3 28-03-2005 Day 3
|
||||
SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC;
|
||||
id date_ord text
|
||||
3 28-03-2005 Day 3
|
||||
2 16-03-2005 Day 2
|
||||
1 05-03-2005 Day 1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a CHAR(10));
|
||||
INSERT INTO t1 VALUES ('aaa'), (NULL), (''), ('bbb');
|
||||
SELECT a, NULLIF(a,'') FROM t1;
|
||||
a NULLIF(a,'')
|
||||
aaa aaa
|
||||
NULL NULL
|
||||
NULL
|
||||
bbb bbb
|
||||
SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL;
|
||||
a NULLIF(a,'')
|
||||
NULL NULL
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
create table t1 (f1 int, f2 int);
|
||||
insert into t1 values(1,1),(0,0);
|
||||
select f1, f2, if(f1, 40.0, 5.00) from t1 group by f1 order by f2;
|
||||
f1 f2 if(f1, 40.0, 5.00)
|
||||
0 0 5.00
|
||||
1 1 40.00
|
||||
drop table t1;
|
@ -1,442 +0,0 @@
|
||||
drop table if exists t1, t2;
|
||||
select 1 in (1,2,3);
|
||||
1 in (1,2,3)
|
||||
1
|
||||
select 10 in (1,2,3);
|
||||
10 in (1,2,3)
|
||||
0
|
||||
select NULL in (1,2,3);
|
||||
NULL in (1,2,3)
|
||||
NULL
|
||||
select 1 in (1,NULL,3);
|
||||
1 in (1,NULL,3)
|
||||
1
|
||||
select 3 in (1,NULL,3);
|
||||
3 in (1,NULL,3)
|
||||
1
|
||||
select 10 in (1,NULL,3);
|
||||
10 in (1,NULL,3)
|
||||
NULL
|
||||
select 1.5 in (1.5,2.5,3.5);
|
||||
1.5 in (1.5,2.5,3.5)
|
||||
1
|
||||
select 10.5 in (1.5,2.5,3.5);
|
||||
10.5 in (1.5,2.5,3.5)
|
||||
0
|
||||
select NULL in (1.5,2.5,3.5);
|
||||
NULL in (1.5,2.5,3.5)
|
||||
NULL
|
||||
select 1.5 in (1.5,NULL,3.5);
|
||||
1.5 in (1.5,NULL,3.5)
|
||||
1
|
||||
select 3.5 in (1.5,NULL,3.5);
|
||||
3.5 in (1.5,NULL,3.5)
|
||||
1
|
||||
select 10.5 in (1.5,NULL,3.5);
|
||||
10.5 in (1.5,NULL,3.5)
|
||||
NULL
|
||||
CREATE TABLE t1 (a int, b int, c int);
|
||||
insert into t1 values (1,2,3), (1,NULL,3);
|
||||
select 1 in (a,b,c) from t1;
|
||||
1 in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 3 in (a,b,c) from t1;
|
||||
3 in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 10 in (a,b,c) from t1;
|
||||
10 in (a,b,c)
|
||||
0
|
||||
NULL
|
||||
select NULL in (a,b,c) from t1;
|
||||
NULL in (a,b,c)
|
||||
NULL
|
||||
NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a float, b float, c float);
|
||||
insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5);
|
||||
select 1.5 in (a,b,c) from t1;
|
||||
1.5 in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 3.5 in (a,b,c) from t1;
|
||||
3.5 in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 10.5 in (a,b,c) from t1;
|
||||
10.5 in (a,b,c)
|
||||
0
|
||||
NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10));
|
||||
insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD');
|
||||
select 'A' in (a,b,c) from t1;
|
||||
'A' in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 'EFD' in (a,b,c) from t1;
|
||||
'EFD' in (a,b,c)
|
||||
1
|
||||
1
|
||||
select 'XSFGGHF' in (a,b,c) from t1;
|
||||
'XSFGGHF' in (a,b,c)
|
||||
0
|
||||
NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (field char(1));
|
||||
INSERT INTO t1 VALUES ('A'),(NULL);
|
||||
SELECT * from t1 WHERE field IN (NULL);
|
||||
field
|
||||
SELECT * from t1 WHERE field NOT IN (NULL);
|
||||
field
|
||||
SELECT * from t1 where field = field;
|
||||
field
|
||||
A
|
||||
SELECT * from t1 where field <=> field;
|
||||
field
|
||||
A
|
||||
NULL
|
||||
DELETE FROM t1 WHERE field NOT IN (NULL);
|
||||
SELECT * FROM t1;
|
||||
field
|
||||
A
|
||||
NULL
|
||||
drop table t1;
|
||||
create table t1 (id int(10) primary key);
|
||||
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
select * from t1 where id in (2,5,9);
|
||||
id
|
||||
2
|
||||
5
|
||||
9
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
a char(1) character set latin1 collate latin1_general_ci,
|
||||
b char(1) character set latin1 collate latin1_swedish_ci,
|
||||
c char(1) character set latin1 collate latin1_danish_ci
|
||||
);
|
||||
insert into t1 values ('A','B','C');
|
||||
insert into t1 values ('a','c','c');
|
||||
select * from t1 where a in (b);
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
|
||||
select * from t1 where a in (b,c);
|
||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN '
|
||||
select * from t1 where 'a' in (a,b,c);
|
||||
ERROR HY000: Illegal mix of collations for operation ' IN '
|
||||
select * from t1 where 'a' in (a);
|
||||
a b c
|
||||
A B C
|
||||
a c c
|
||||
select * from t1 where a in ('a');
|
||||
a b c
|
||||
A B C
|
||||
a c c
|
||||
select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
|
||||
a b c
|
||||
A B C
|
||||
a c c
|
||||
select * from t1 where 'a' collate latin1_bin in (a,b,c);
|
||||
a b c
|
||||
a c c
|
||||
select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
||||
a b c
|
||||
a c c
|
||||
explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ('a' in (`test`.`t1`.`a`,`test`.`t1`.`b`,(`test`.`t1`.`c` collate latin1_bin)))
|
||||
drop table t1;
|
||||
set names utf8;
|
||||
create table t1 (a char(10) character set utf8 not null);
|
||||
insert into t1 values ('bbbb'),(_koi8r'ÃÃÃÃ'),(_latin1'ÄÄÄÄ');
|
||||
select a from t1 where a in ('bbbb',_koi8r'ÃÃÃÃ',_latin1'ÄÄÄÄ') order by a;
|
||||
a
|
||||
ÄÄÄÄ
|
||||
bbbb
|
||||
цццц
|
||||
drop table t1;
|
||||
create table t1 (a char(10) character set latin1 not null);
|
||||
insert into t1 values ('a'),('b'),('c');
|
||||
select a from t1 where a IN ('a','b','c') order by a;
|
||||
a
|
||||
a
|
||||
b
|
||||
c
|
||||
drop table t1;
|
||||
set names latin1;
|
||||
select '1.0' in (1,2);
|
||||
'1.0' in (1,2)
|
||||
1
|
||||
select 1 in ('1.0',2);
|
||||
1 in ('1.0',2)
|
||||
1
|
||||
select 1 in (1,'2.0');
|
||||
1 in (1,'2.0')
|
||||
1
|
||||
select 1 in ('1.0',2.0);
|
||||
1 in ('1.0',2.0)
|
||||
1
|
||||
select 1 in (1.0,'2.0');
|
||||
1 in (1.0,'2.0')
|
||||
1
|
||||
select 1 in ('1.1',2);
|
||||
1 in ('1.1',2)
|
||||
0
|
||||
select 1 in ('1.1',2.0);
|
||||
1 in ('1.1',2.0)
|
||||
0
|
||||
create table t1 (a char(2) character set binary);
|
||||
insert into t1 values ('aa'), ('bb');
|
||||
select * from t1 where a in (NULL, 'aa');
|
||||
a
|
||||
aa
|
||||
drop table t1;
|
||||
create table t1 (id int, key(id));
|
||||
insert into t1 values (1),(2),(3);
|
||||
select count(*) from t1 where id not in (1);
|
||||
count(*)
|
||||
2
|
||||
select count(*) from t1 where id not in (1,2);
|
||||
count(*)
|
||||
1
|
||||
drop table t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 SELECT 1 IN (2, NULL);
|
||||
SELECT should return NULL.
|
||||
SELECT * FROM t1;
|
||||
1 IN (2, NULL)
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
End of 4.1 tests
|
||||
CREATE TABLE t1 (a int PRIMARY KEY);
|
||||
INSERT INTO t1 VALUES (44), (45), (46);
|
||||
SELECT * FROM t1 WHERE a IN (45);
|
||||
a
|
||||
45
|
||||
SELECT * FROM t1 WHERE a NOT IN (0, 45);
|
||||
a
|
||||
44
|
||||
46
|
||||
SELECT * FROM t1 WHERE a NOT IN (45);
|
||||
a
|
||||
44
|
||||
46
|
||||
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45);
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` <> 45) latin1 latin1_swedish_ci
|
||||
SELECT * FROM v1;
|
||||
a
|
||||
44
|
||||
46
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t2 (a int, filler char(200), key(a));
|
||||
insert into t2 select C.a*2, 'no' from t1 A, t1 B, t1 C;
|
||||
insert into t2 select C.a*2+1, 'yes' from t1 C;
|
||||
explain
|
||||
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 5 NULL 11 Using where
|
||||
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
|
||||
a filler
|
||||
1 yes
|
||||
3 yes
|
||||
5 yes
|
||||
7 yes
|
||||
9 yes
|
||||
11 yes
|
||||
13 yes
|
||||
15 yes
|
||||
17 yes
|
||||
19 yes
|
||||
explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 5 NULL # Using where
|
||||
explain select * from t2 force index(a) where a <> 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 5 NULL # Using where
|
||||
drop table t2;
|
||||
create table t2 (a datetime, filler char(200), key(a));
|
||||
insert into t2 select '2006-04-25 10:00:00' + interval C.a minute,
|
||||
'no' from t1 A, t1 B, t1 C where C.a % 2 = 0;
|
||||
insert into t2 select '2006-04-25 10:00:00' + interval C.a*2+1 minute,
|
||||
'yes' from t1 C;
|
||||
explain
|
||||
select * from t2 where a NOT IN (
|
||||
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
|
||||
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 9 NULL 6 Using where
|
||||
select * from t2 where a NOT IN (
|
||||
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00',
|
||||
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
|
||||
a filler
|
||||
2006-04-25 10:01:00 yes
|
||||
2006-04-25 10:03:00 yes
|
||||
2006-04-25 10:05:00 yes
|
||||
2006-04-25 10:07:00 yes
|
||||
2006-04-25 10:09:00 yes
|
||||
2006-04-25 10:11:00 yes
|
||||
2006-04-25 10:13:00 yes
|
||||
2006-04-25 10:15:00 yes
|
||||
2006-04-25 10:17:00 yes
|
||||
2006-04-25 10:19:00 yes
|
||||
drop table t2;
|
||||
create table t2 (a varchar(10), filler char(200), key(a));
|
||||
insert into t2 select 'foo', 'no' from t1 A, t1 B;
|
||||
insert into t2 select 'barbar', 'no' from t1 A, t1 B;
|
||||
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B;
|
||||
insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'),
|
||||
('barbas','1'), ('bazbazbay', '1'),('zz','1');
|
||||
analyze table t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status OK
|
||||
explain select * from t2 where a not in('foo','barbar', 'bazbazbaz');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 13 NULL 4 Using where
|
||||
drop table t2;
|
||||
create table t2 (a decimal(10,5), filler char(200), key(a));
|
||||
insert into t2 select 345.67890, 'no' from t1 A, t1 B;
|
||||
insert into t2 select 43245.34, 'no' from t1 A, t1 B;
|
||||
insert into t2 select 64224.56344, 'no' from t1 A, t1 B;
|
||||
insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'),
|
||||
(55555,'1'), (77777, '1');
|
||||
analyze table t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status OK
|
||||
explain
|
||||
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a a 7 NULL 4 Using where
|
||||
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
|
||||
a filler
|
||||
0.00000 1
|
||||
22334.12300 1
|
||||
33333.00000 1
|
||||
55555.00000 1
|
||||
77777.00000 1
|
||||
drop table t2;
|
||||
create table t2 (a int, key(a), b int);
|
||||
insert into t2 values (1,1),(2,2);
|
||||
set @cnt= 1;
|
||||
set @str="update t2 set b=1 where a not in (";
|
||||
select count(*) from (
|
||||
select @str:=concat(@str, @cnt:=@cnt+1, ",")
|
||||
from t1 A, t1 B, t1 C, t1 D) Z;
|
||||
count(*)
|
||||
10000
|
||||
set @str:=concat(@str, "10000)");
|
||||
select substr(@str, 1, 50);
|
||||
substr(@str, 1, 50)
|
||||
update t2 set b=1 where a not in (2,3,4,5,6,7,8,9,
|
||||
prepare s from @str;
|
||||
execute s;
|
||||
deallocate prepare s;
|
||||
set @str=NULL;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
some_id smallint(5) unsigned,
|
||||
key (some_id)
|
||||
);
|
||||
insert into t1 values (1),(2);
|
||||
select some_id from t1 where some_id not in(2,-1);
|
||||
some_id
|
||||
1
|
||||
select some_id from t1 where some_id not in(-4,-1,-4);
|
||||
some_id
|
||||
1
|
||||
2
|
||||
select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
|
||||
some_id
|
||||
1
|
||||
2
|
||||
select some_id from t1 where some_id not in('-1', '0');
|
||||
some_id
|
||||
1
|
||||
2
|
||||
drop table t1;
|
||||
End of 5.0 tests
|
||||
create table t1(f1 char(1));
|
||||
insert into t1 values ('a'),('b'),('1');
|
||||
select f1 from t1 where f1 in ('a',1);
|
||||
f1
|
||||
a
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
select f1, case f1 when 'a' then '+' when 1 then '-' end from t1;
|
||||
f1 case f1 when 'a' then '+' when 1 then '-' end
|
||||
a +
|
||||
b NULL
|
||||
1 -
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
create index t1f1_idx on t1(f1);
|
||||
select f1 from t1 where f1 in ('a',1);
|
||||
f1
|
||||
1
|
||||
a
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
explain select f1 from t1 where f1 in ('a',1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
|
||||
select f1 from t1 where f1 in ('a','b');
|
||||
f1
|
||||
a
|
||||
b
|
||||
explain select f1 from t1 where f1 in ('a','b');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
|
||||
select f1 from t1 where f1 in (2,1);
|
||||
f1
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
explain select f1 from t1 where f1 in (2,1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
|
||||
create table t2(f2 int, index t2f2(f2));
|
||||
insert into t2 values(0),(1),(2);
|
||||
select f2 from t2 where f2 in ('a',2);
|
||||
f2
|
||||
0
|
||||
2
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
explain select f2 from t2 where f2 in ('a',2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
||||
select f2 from t2 where f2 in ('a','b');
|
||||
f2
|
||||
0
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
explain select f2 from t2 where f2 in ('a','b');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
select f2 from t2 where f2 in (1,'b');
|
||||
f2
|
||||
0
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'b'
|
||||
explain select f2 from t2 where f2 in (1,'b');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
|
||||
drop table t1, t2;
|
||||
End of 5.1 tests
|
@ -1,7 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (id int auto_increment primary key not null, mydate date not null);
|
||||
insert into t1 values (0,"2002-05-01"),(0,"2002-05-01"),(0,"2002-05-01");
|
||||
flush tables;
|
||||
select * from t1 where isnull(to_days(mydate));
|
||||
id mydate
|
||||
drop table t1;
|
@ -1,171 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a varchar(10), key(a));
|
||||
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
||||
explain extended select * from t1 where a like 'abc%';
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like 'abc%')
|
||||
explain extended select * from t1 where a like concat('abc','%');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 index a a 13 NULL 5 20.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` like <cache>(concat('abc','%')))
|
||||
select * from t1 where a like "abc%";
|
||||
a
|
||||
abc
|
||||
abcd
|
||||
select * from t1 where a like concat("abc","%");
|
||||
a
|
||||
abc
|
||||
abcd
|
||||
select * from t1 where a like "ABC%";
|
||||
a
|
||||
abc
|
||||
abcd
|
||||
select * from t1 where a like "test%";
|
||||
a
|
||||
test
|
||||
select * from t1 where a like "te_t";
|
||||
a
|
||||
test
|
||||
select * from t1 where a like "%a%";
|
||||
a
|
||||
a
|
||||
abc
|
||||
abcd
|
||||
select * from t1 where a like "%abcd%";
|
||||
a
|
||||
abcd
|
||||
select * from t1 where a like "%abc\d%";
|
||||
a
|
||||
abcd
|
||||
drop table t1;
|
||||
create table t1 (a varchar(10), key(a));
|
||||
insert into t1 values ('a'), ('a\\b');
|
||||
select * from t1 where a like 'a\\%' escape '#';
|
||||
a
|
||||
a\b
|
||||
select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b';
|
||||
a
|
||||
a\b
|
||||
prepare stmt1 from 'select * from t1 where a like \'a\\%\' escape ?';
|
||||
set @esc='#';
|
||||
execute stmt1 using @esc;
|
||||
a
|
||||
a\b
|
||||
deallocate prepare stmt1;
|
||||
drop table t1;
|
||||
create table t1 (a datetime);
|
||||
insert into t1 values ('2004-03-11 12:00:21');
|
||||
select * from t1 where a like '2004-03-11 12:00:21';
|
||||
a
|
||||
2004-03-11 12:00:21
|
||||
drop table t1;
|
||||
SET NAMES koi8r;
|
||||
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r);
|
||||
INSERT INTO t1 VALUES ('ÆÙ×Á'),('æÙ×Á'),('Æù×Á'),('ÆÙ÷Á'),('ÆÙ×á'),('æù÷á');
|
||||
INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏÌÄÖ'),('æÙ×ÁÐÒÏÌÄÖ'),('Æù×ÁÐÒÏÌÄÖ'),('ÆÙ÷ÁÐÒÏÌÄÖ');
|
||||
INSERT INTO t1 VALUES ('ÆÙ×áÐÒÏÌÄÖ'),('ÆÙ×ÁðÒÏÌÄÖ'),('ÆÙ×ÁÐòÏÌÄÖ'),('ÆÙ×ÁÐÒïÌÄÖ');
|
||||
INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏìÄÖ'),('ÆÙ×ÁÐÒÏÌäÖ'),('ÆÙ×ÁÐÒÏÌÄö'),('æù÷áðòïìäö');
|
||||
SELECT * FROM t1 WHERE a LIKE '%Æù×Á%';
|
||||
a
|
||||
ÆÙ×Á
|
||||
æÙ×Á
|
||||
Æù×Á
|
||||
ÆÙ÷Á
|
||||
ÆÙ×á
|
||||
æù÷á
|
||||
ÆÙ×ÁÐÒÏÌÄÖ
|
||||
æÙ×ÁÐÒÏÌÄÖ
|
||||
Æù×ÁÐÒÏÌÄÖ
|
||||
ÆÙ÷ÁÐÒÏÌÄÖ
|
||||
ÆÙ×áÐÒÏÌÄÖ
|
||||
ÆÙ×ÁðÒÏÌÄÖ
|
||||
ÆÙ×ÁÐòÏÌÄÖ
|
||||
ÆÙ×ÁÐÒïÌÄÖ
|
||||
ÆÙ×ÁÐÒÏìÄÖ
|
||||
ÆÙ×ÁÐÒÏÌäÖ
|
||||
ÆÙ×ÁÐÒÏÌÄö
|
||||
æù÷áðòïìäö
|
||||
SELECT * FROM t1 WHERE a LIKE '%Æù×%';
|
||||
a
|
||||
ÆÙ×Á
|
||||
æÙ×Á
|
||||
Æù×Á
|
||||
ÆÙ÷Á
|
||||
ÆÙ×á
|
||||
æù÷á
|
||||
ÆÙ×ÁÐÒÏÌÄÖ
|
||||
æÙ×ÁÐÒÏÌÄÖ
|
||||
Æù×ÁÐÒÏÌÄÖ
|
||||
ÆÙ÷ÁÐÒÏÌÄÖ
|
||||
ÆÙ×áÐÒÏÌÄÖ
|
||||
ÆÙ×ÁðÒÏÌÄÖ
|
||||
ÆÙ×ÁÐòÏÌÄÖ
|
||||
ÆÙ×ÁÐÒïÌÄÖ
|
||||
ÆÙ×ÁÐÒÏìÄÖ
|
||||
ÆÙ×ÁÐÒÏÌäÖ
|
||||
ÆÙ×ÁÐÒÏÌÄö
|
||||
æù÷áðòïìäö
|
||||
SELECT * FROM t1 WHERE a LIKE 'Æù×Á%';
|
||||
a
|
||||
ÆÙ×Á
|
||||
æÙ×Á
|
||||
Æù×Á
|
||||
ÆÙ÷Á
|
||||
ÆÙ×á
|
||||
æù÷á
|
||||
ÆÙ×ÁÐÒÏÌÄÖ
|
||||
æÙ×ÁÐÒÏÌÄÖ
|
||||
Æù×ÁÐÒÏÌÄÖ
|
||||
ÆÙ÷ÁÐÒÏÌÄÖ
|
||||
ÆÙ×áÐÒÏÌÄÖ
|
||||
ÆÙ×ÁðÒÏÌÄÖ
|
||||
ÆÙ×ÁÐòÏÌÄÖ
|
||||
ÆÙ×ÁÐÒïÌÄÖ
|
||||
ÆÙ×ÁÐÒÏìÄÖ
|
||||
ÆÙ×ÁÐÒÏÌäÖ
|
||||
ÆÙ×ÁÐÒÏÌÄö
|
||||
æù÷áðòïìäö
|
||||
DROP TABLE t1;
|
||||
SET NAMES cp1250;
|
||||
CREATE TABLE t1 (a varchar(250) NOT NULL) DEFAULT CHARACTER SET=cp1250;
|
||||
INSERT INTO t1 VALUES
|
||||
('Techni Tapes Sp. z o.o.'),
|
||||
('Pojazdy Szynowe PESA Bydgoszcz SA Holding'),
|
||||
('AKAPESTER 1 P.P.H.U.'),
|
||||
('Pojazdy Szynowe PESA Bydgoszcz S A Holding'),
|
||||
('PPUH PESKA-I Maria Struniarska');
|
||||
select * from t1 where a like '%PESA%';
|
||||
a
|
||||
Pojazdy Szynowe PESA Bydgoszcz SA Holding
|
||||
Pojazdy Szynowe PESA Bydgoszcz S A Holding
|
||||
select * from t1 where a like '%PESA %';
|
||||
a
|
||||
Pojazdy Szynowe PESA Bydgoszcz SA Holding
|
||||
Pojazdy Szynowe PESA Bydgoszcz S A Holding
|
||||
select * from t1 where a like '%PES%';
|
||||
a
|
||||
Techni Tapes Sp. z o.o.
|
||||
Pojazdy Szynowe PESA Bydgoszcz SA Holding
|
||||
AKAPESTER 1 P.P.H.U.
|
||||
Pojazdy Szynowe PESA Bydgoszcz S A Holding
|
||||
PPUH PESKA-I Maria Struniarska
|
||||
select * from t1 where a like '%PESKA%';
|
||||
a
|
||||
PPUH PESKA-I Maria Struniarska
|
||||
select * from t1 where a like '%ESKA%';
|
||||
a
|
||||
PPUH PESKA-I Maria Struniarska
|
||||
DROP TABLE t1;
|
||||
select _cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin;
|
||||
_cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin
|
||||
1
|
||||
set names koi8r;
|
||||
select 'andre%' like 'andreÊ%' escape 'Ê';
|
||||
'andre%' like 'andreÊ%' escape 'Ê'
|
||||
1
|
||||
select _cp1251'andre%' like convert('andreÊ%' using cp1251) escape 'Ê';
|
||||
_cp1251'andre%' like convert('andreÊ%' using cp1251) escape 'Ê'
|
||||
1
|
@ -1,287 +0,0 @@
|
||||
drop table if exists t1;
|
||||
select floor(5.5),floor(-5.5);
|
||||
floor(5.5) floor(-5.5)
|
||||
5 -6
|
||||
explain extended select floor(5.5),floor(-5.5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select floor(5.5) AS `floor(5.5)`,floor(-(5.5)) AS `floor(-5.5)`
|
||||
select ceiling(5.5),ceiling(-5.5);
|
||||
ceiling(5.5) ceiling(-5.5)
|
||||
6 -5
|
||||
explain extended select ceiling(5.5),ceiling(-5.5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-(5.5)) AS `ceiling(-5.5)`
|
||||
select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
|
||||
truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1)
|
||||
52.6 52.64 50 0 -52.6 -50
|
||||
explain extended select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select truncate(52.64,1) AS `truncate(52.64,1)`,truncate(52.64,2) AS `truncate(52.64,2)`,truncate(52.64,-(1)) AS `truncate(52.64,-1)`,truncate(52.64,-(2)) AS `truncate(52.64,-2)`,truncate(-(52.64),1) AS `truncate(-52.64,1)`,truncate(-(52.64),-(1)) AS `truncate(-52.64,-1)`
|
||||
select round(5.5),round(-5.5);
|
||||
round(5.5) round(-5.5)
|
||||
6 -6
|
||||
explain extended select round(5.5),round(-5.5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select round(5.5,0) AS `round(5.5)`,round(-(5.5),0) AS `round(-5.5)`
|
||||
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
|
||||
round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2)
|
||||
5.6 5.64 10 0
|
||||
select abs(-10), sign(-5), sign(5), sign(0);
|
||||
abs(-10) sign(-5) sign(5) sign(0)
|
||||
10 -1 1 0
|
||||
explain extended select abs(-10), sign(-5), sign(5), sign(0);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
|
||||
select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
|
||||
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
|
||||
10 10.000000000000002 NULL NULL NULL 2 NULL NULL
|
||||
explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-(1)) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-(1),2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
|
||||
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
|
||||
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
|
||||
10 10.000000000000002 NULL NULL NULL
|
||||
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
|
||||
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
|
||||
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
|
||||
3 3.9068905956085187 NULL NULL NULL
|
||||
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
|
||||
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
|
||||
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
|
||||
2 1.255272505103306 NULL NULL NULL
|
||||
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-(4)) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)`
|
||||
select pow(10,log10(10)),power(2,4);
|
||||
pow(10,log10(10)) power(2,4)
|
||||
10 16
|
||||
explain extended select pow(10,log10(10)),power(2,4);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4)`
|
||||
set @@rand_seed1=10000000,@@rand_seed2=1000000;
|
||||
select rand(999999),rand();
|
||||
rand(999999) rand()
|
||||
0.014231365187309091 0.028870999839968048
|
||||
explain extended select rand(999999),rand();
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select rand(999999) AS `rand(999999)`,rand() AS `rand()`
|
||||
select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
|
||||
pi() format(sin(pi()/2),6) format(cos(pi()/2),6) format(abs(tan(pi())),6) format(cot(1),6) format(asin(1),6) format(acos(0),6) format(atan(1),6)
|
||||
3.141593 1.000000 0.000000 0.000000 0.642093 1.570796 1.570796 0.785398
|
||||
explain extended select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format(cot(1),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
|
||||
select degrees(pi()),radians(360);
|
||||
degrees(pi()) radians(360)
|
||||
180 6.283185307179586
|
||||
select format(atan(-2, 2), 6);
|
||||
format(atan(-2, 2), 6)
|
||||
-0.785398
|
||||
select format(atan(pi(), 0), 6);
|
||||
format(atan(pi(), 0), 6)
|
||||
1.570796
|
||||
select format(atan2(-2, 2), 6);
|
||||
format(atan2(-2, 2), 6)
|
||||
-0.785398
|
||||
select format(atan2(pi(), 0), 6);
|
||||
format(atan2(pi(), 0), 6)
|
||||
1.570796
|
||||
SELECT ACOS(1.0);
|
||||
ACOS(1.0)
|
||||
0
|
||||
SELECT ASIN(1.0);
|
||||
ASIN(1.0)
|
||||
1.5707963267948966
|
||||
SELECT ACOS(0.2*5.0);
|
||||
ACOS(0.2*5.0)
|
||||
0
|
||||
SELECT ACOS(0.5*2.0);
|
||||
ACOS(0.5*2.0)
|
||||
0
|
||||
SELECT ASIN(0.8+0.2);
|
||||
ASIN(0.8+0.2)
|
||||
1.5707963267948966
|
||||
SELECT ASIN(1.2-0.2);
|
||||
ASIN(1.2-0.2)
|
||||
1.5707963267948966
|
||||
select format(4.55, 1), format(4.551, 1);
|
||||
format(4.55, 1) format(4.551, 1)
|
||||
4.6 4.6
|
||||
explain extended select degrees(pi()),radians(360);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)`
|
||||
select rand(rand);
|
||||
ERROR 42S22: Unknown column 'rand' in 'field list'
|
||||
create table t1 (col1 int, col2 decimal(60,30));
|
||||
insert into t1 values(1,1234567890.12345);
|
||||
select format(col2,7) from t1;
|
||||
format(col2,7)
|
||||
1,234,567,890.1234500
|
||||
select format(col2,8) from t1;
|
||||
format(col2,8)
|
||||
1,234,567,890.12345000
|
||||
insert into t1 values(7,1234567890123456.12345);
|
||||
select format(col2,6) from t1 where col1=7;
|
||||
format(col2,6)
|
||||
1,234,567,890,123,456.123450
|
||||
drop table t1;
|
||||
select round(150, 2);
|
||||
round(150, 2)
|
||||
150
|
||||
select ceil(0.09);
|
||||
ceil(0.09)
|
||||
1
|
||||
select ceil(0.000000000000000009);
|
||||
ceil(0.000000000000000009)
|
||||
1
|
||||
create table t1 select round(1, 6);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`round(1, 6)` int(1) NOT NULL DEFAULT '0'
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
select * from t1;
|
||||
round(1, 6)
|
||||
1
|
||||
drop table t1;
|
||||
select abs(-2) * -2;
|
||||
abs(-2) * -2
|
||||
-4
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(1),(1),(2);
|
||||
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
FROM t1;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
656 405
|
||||
122 405
|
||||
645 405
|
||||
858 656
|
||||
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
FROM t1 WHERE a = 1;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
656 405
|
||||
122 405
|
||||
645 405
|
||||
INSERT INTO t1 VALUES (3);
|
||||
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
FROM t1;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
656 405
|
||||
122 405
|
||||
645 405
|
||||
858 656
|
||||
354 906
|
||||
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
FROM t1 WHERE a = 1;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
|
||||
656 405
|
||||
122 405
|
||||
645 405
|
||||
PREPARE stmt FROM
|
||||
"SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(?) * 1000 AS UNSIGNED)
|
||||
FROM t1 WHERE a = 1";
|
||||
set @var=2;
|
||||
EXECUTE stmt USING @var;
|
||||
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(?) * 1000 AS UNSIGNED)
|
||||
656 656
|
||||
122 122
|
||||
645 645
|
||||
DROP TABLE t1;
|
||||
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
|
||||
insert into t1 values ('http://www.foo.com/', now());
|
||||
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
|
||||
a
|
||||
http://www.foo.com/
|
||||
drop table t1;
|
||||
set sql_mode='traditional';
|
||||
select ln(-1);
|
||||
ln(-1)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1365 Division by 0
|
||||
select log10(-1);
|
||||
log10(-1)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1365 Division by 0
|
||||
select log2(-1);
|
||||
log2(-1)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1365 Division by 0
|
||||
select log(2,-1);
|
||||
log(2,-1)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1365 Division by 0
|
||||
select log(-2,1);
|
||||
log(-2,1)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1365 Division by 0
|
||||
set sql_mode='';
|
||||
select round(111,-10);
|
||||
round(111,-10)
|
||||
0
|
||||
select round(-5000111000111000155,-1);
|
||||
round(-5000111000111000155,-1)
|
||||
-5000111000111000160
|
||||
select round(15000111000111000155,-1);
|
||||
round(15000111000111000155,-1)
|
||||
15000111000111000160
|
||||
select truncate(-5000111000111000155,-1);
|
||||
truncate(-5000111000111000155,-1)
|
||||
-5000111000111000150
|
||||
select truncate(15000111000111000155,-1);
|
||||
truncate(15000111000111000155,-1)
|
||||
15000111000111000150
|
||||
set names utf8;
|
||||
create table t1
|
||||
(f1 varchar(32) not null,
|
||||
f2 smallint(5) unsigned not null,
|
||||
f3 int(10) unsigned not null default '0')
|
||||
engine=myisam default charset=utf8;
|
||||
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000);
|
||||
create table t2
|
||||
(f1 int(10) unsigned not null,
|
||||
f2 int(10) unsigned not null,
|
||||
f3 smallint(5) unsigned not null)
|
||||
engine=myisam default charset=utf8;
|
||||
insert into t2 values (16777216,16787215,1),(33554432,33564431,2);
|
||||
select format(t2.f2-t2.f1+1,0) from t1,t2
|
||||
where t1.f2 = t2.f3 order by t1.f1;
|
||||
format(t2.f2-t2.f1+1,0)
|
||||
10,000
|
||||
10,000
|
||||
drop table t1, t2;
|
||||
set names default;
|
@ -1,144 +0,0 @@
|
||||
select format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.55555,3),format(123456.5555,4),format(1234567.5555,5),format("12345.2399",2);
|
||||
format(1.5555,0) format(123.5555,1) format(1234.5555,2) format(12345.55555,3) format(123456.5555,4) format(1234567.5555,5) format("12345.2399",2)
|
||||
2 123.6 1,234.56 12,345.556 123,456.5555 1,234,567.55550 12,345.24
|
||||
select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"));
|
||||
inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"))
|
||||
NULL
|
||||
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
|
||||
inet_aton("255.255.255.255.255") inet_aton("255.255.1.255") inet_aton("0.1.255")
|
||||
1099511627775 4294902271 65791
|
||||
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
|
||||
inet_ntoa(1099511627775) inet_ntoa(4294902271) inet_ntoa(511)
|
||||
NULL 255.255.1.255 0.0.1.255
|
||||
select hex(inet_aton('127'));
|
||||
hex(inet_aton('127'))
|
||||
7F
|
||||
select hex(inet_aton('127.1'));
|
||||
hex(inet_aton('127.1'))
|
||||
7F000001
|
||||
select hex(inet_aton('127.1.1'));
|
||||
hex(inet_aton('127.1.1'))
|
||||
7F010001
|
||||
select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8'')));
|
||||
length(uuid()) charset(uuid()) length(unhex(replace(uuid(),_utf8'-',_utf8'')))
|
||||
36 utf8 16
|
||||
select length(format('nan', 2)) > 0;
|
||||
length(format('nan', 2)) > 0
|
||||
1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'nan'
|
||||
select concat("$",format(2500,2));
|
||||
concat("$",format(2500,2))
|
||||
$2,500.00
|
||||
create table t1 ( a timestamp );
|
||||
insert into t1 values ( '2004-01-06 12:34' );
|
||||
select a from t1 where left(a+0,6) in ( left(20040106,6) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where left(a+0,6) = ( left(20040106,6) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where right(a+0,6) in ( right(20040106123400,6) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where right(a+0,6) = ( right(20040106123400,6) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where mid(a+0,6,3) in ( mid(20040106123400,6,3) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) );
|
||||
a
|
||||
2004-01-06 12:34:00
|
||||
drop table t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (conn CHAR(7), connection_id INT);
|
||||
INSERT INTO t1 VALUES ('default', CONNECTION_ID());
|
||||
SELECT GET_LOCK('bug16501',600);
|
||||
GET_LOCK('bug16501',600)
|
||||
1
|
||||
INSERT INTO t1 VALUES ('con1', CONNECTION_ID());
|
||||
SELECT IS_USED_LOCK('bug16501') = connection_id
|
||||
FROM t1
|
||||
WHERE conn = 'default';
|
||||
IS_USED_LOCK('bug16501') = connection_id
|
||||
1
|
||||
SELECT GET_LOCK('bug16501',600);
|
||||
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
|
||||
IS_USED_LOCK('bug16501') = CONNECTION_ID()
|
||||
1
|
||||
SELECT RELEASE_LOCK('bug16501');
|
||||
RELEASE_LOCK('bug16501')
|
||||
1
|
||||
GET_LOCK('bug16501',600)
|
||||
1
|
||||
SELECT IS_USED_LOCK('bug16501') = connection_id
|
||||
FROM t1
|
||||
WHERE conn = 'con1';
|
||||
IS_USED_LOCK('bug16501') = connection_id
|
||||
1
|
||||
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
|
||||
IS_USED_LOCK('bug16501') = CONNECTION_ID()
|
||||
1
|
||||
SELECT RELEASE_LOCK('bug16501');
|
||||
RELEASE_LOCK('bug16501')
|
||||
1
|
||||
SELECT IS_USED_LOCK('bug16501');
|
||||
IS_USED_LOCK('bug16501')
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
|
||||
export_set(3, _latin1'foo', _utf8'bar', ',', 4)
|
||||
foo,foo,bar,bar
|
||||
End of 4.1 tests
|
||||
create table t1 as select uuid(), length(uuid());
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`uuid()` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`length(uuid())` int(10) NOT NULL DEFAULT '0'
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a timestamp default '2005-05-05 01:01:01',
|
||||
b timestamp default '2005-05-05 01:01:01');
|
||||
insert into t1 set a = now();
|
||||
select sleep(3);
|
||||
sleep(3)
|
||||
0
|
||||
update t1 set b = now();
|
||||
select timediff(b, a) >= '00:00:03' from t1;
|
||||
timediff(b, a) >= '00:00:03'
|
||||
1
|
||||
drop table t1;
|
||||
set global query_cache_size=1355776;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(1),(1);
|
||||
create table t2 (a datetime default null, b datetime default null);
|
||||
insert into t2 set a = now();
|
||||
select a from t1 where sleep(1);
|
||||
a
|
||||
update t2 set b = now() where b is null;
|
||||
insert into t2 set a = now();
|
||||
select a from t1 where sleep(a);
|
||||
a
|
||||
update t2 set b = now() where b is null;
|
||||
insert into t2 set a = now();
|
||||
select a from t1 where sleep(1);
|
||||
a
|
||||
update t2 set b = now() where b is null;
|
||||
select timediff(b, a) >= '00:00:03' from t2;
|
||||
timediff(b, a) >= '00:00:03'
|
||||
1
|
||||
1
|
||||
1
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
set global query_cache_size=default;
|
||||
create table t1 select INET_ATON('255.255.0.1') as `a`;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` bigint(21) unsigned DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
End of 5.0 tests
|
@ -1,51 +0,0 @@
|
||||
select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
|
||||
1+1 1-1 1+1*2 8/5 8%5 mod(8,5) mod(8,5)|0 -(1+1)*-2
|
||||
2 0 3 1.6000 3 3 3 4
|
||||
explain extended select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select (1 + 1) AS `1+1`,(1 - 1) AS `1-1`,(1 + (1 * 2)) AS `1+1*2`,(8 / 5) AS `8/5`,(8 % 5) AS `8%5`,(8 % 5) AS `mod(8,5)`,((8 % 5) | 0) AS `mod(8,5)|0`,(-((1 + 1)) * -(2)) AS `-(1+1)*-2`
|
||||
select 1 | (1+1),5 & 3,bit_count(7) ;
|
||||
1 | (1+1) 5 & 3 bit_count(7)
|
||||
3 1 3
|
||||
explain extended select 1 | (1+1),5 & 3,bit_count(7) ;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select (1 | (1 + 1)) AS `1 | (1+1)`,(5 & 3) AS `5 & 3`,bit_count(7) AS `bit_count(7)`
|
||||
select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
|
||||
1 << 32 1 << 63 1 << 64 4 >> 2 4 >> 63 1<< 63 >> 60
|
||||
4294967296 9223372036854775808 0 1 0 8
|
||||
select -1 | 0, -1 ^ 0, -1 & 0;
|
||||
-1 | 0 -1 ^ 0 -1 & 0
|
||||
18446744073709551615 18446744073709551615 0
|
||||
select -1 | 1, -1 ^ 1, -1 & 1;
|
||||
-1 | 1 -1 ^ 1 -1 & 1
|
||||
18446744073709551615 18446744073709551614 1
|
||||
select 1 | -1, 1 ^ -1, 1 & -1;
|
||||
1 | -1 1 ^ -1 1 & -1
|
||||
18446744073709551615 18446744073709551614 1
|
||||
select 0 | -1, 0 ^ -1, 0 & -1;
|
||||
0 | -1 0 ^ -1 0 & -1
|
||||
18446744073709551615 18446744073709551615 0
|
||||
select -1 >> 0, -1 << 0;
|
||||
-1 >> 0 -1 << 0
|
||||
18446744073709551615 18446744073709551615
|
||||
select -1 >> 1, -1 << 1;
|
||||
-1 >> 1 -1 << 1
|
||||
9223372036854775807 18446744073709551614
|
||||
drop table if exists t1,t2;
|
||||
create table t1(a int);
|
||||
create table t2(a int, b int);
|
||||
insert into t1 values (1), (2), (3);
|
||||
insert into t2 values (1, 7), (3, 7);
|
||||
SET @save_optimizer_switch=@@optimizer_switch;
|
||||
SET optimizer_switch='outer_join_with_cache=off';
|
||||
select t1.a, t2.a, t2.b, bit_count(t2.b) from t1 left join t2 on t1.a=t2.a;
|
||||
a a b bit_count(t2.b)
|
||||
1 1 7 3
|
||||
2 NULL NULL NULL
|
||||
3 3 7 3
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1, t2;
|
@ -1,100 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (s1 char(64),s2 char(64));
|
||||
insert into t1 values('aaa','aaa');
|
||||
insert into t1 values('aaa|qqq','qqq');
|
||||
insert into t1 values('gheis','^[^a-dXYZ]+$');
|
||||
insert into t1 values('aab','^aa?b');
|
||||
insert into t1 values('Baaan','^Ba*n');
|
||||
insert into t1 values('aaa','qqq|aaa');
|
||||
insert into t1 values('qqq','qqq|aaa');
|
||||
insert into t1 values('bbb','qqq|aaa');
|
||||
insert into t1 values('bbb','qqq');
|
||||
insert into t1 values('aaa','aba');
|
||||
insert into t1 values(null,'abc');
|
||||
insert into t1 values('def',null);
|
||||
insert into t1 values(null,null);
|
||||
insert into t1 values('ghi','ghi[');
|
||||
select HIGH_PRIORITY s1 regexp s2 from t1;
|
||||
s1 regexp s2
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
drop table t1;
|
||||
create table t1 (xxx char(128));
|
||||
insert into t1 (xxx) values('this is a test of some long text to see what happens');
|
||||
select * from t1 where xxx regexp('is a test of some long text to');
|
||||
xxx
|
||||
this is a test of some long text to see what happens
|
||||
explain extended select * from t1 where xxx regexp('is a test of some long text to');
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`xxx` AS `xxx` from `test`.`t1` where (`test`.`t1`.`xxx` regexp 'is a test of some long text to')
|
||||
select * from t1 where xxx regexp('is a test of some long text to ');
|
||||
xxx
|
||||
this is a test of some long text to see what happens
|
||||
select * from t1 where xxx regexp('is a test of some long text to s');
|
||||
xxx
|
||||
this is a test of some long text to see what happens
|
||||
select * from t1 where xxx regexp('is a test of some long text to se');
|
||||
xxx
|
||||
this is a test of some long text to see what happens
|
||||
drop table t1;
|
||||
create table t1 (xxx char(128));
|
||||
insert into t1 (xxx) values('this is some text: to test - out.reg exp (22/45)');
|
||||
select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [[(][0-9]+[/\\][0-9]+[])][ ]*$';
|
||||
xxx
|
||||
this is some text: to test - out.reg exp (22/45)
|
||||
drop table t1;
|
||||
select _latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin;
|
||||
_latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin
|
||||
1
|
||||
select _koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin;
|
||||
_koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin
|
||||
0
|
||||
select _latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin;
|
||||
_latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin
|
||||
0
|
||||
select _koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin;
|
||||
_koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin
|
||||
1
|
||||
select _latin1 0xF7 regexp _latin1 '[[:alpha:]]';
|
||||
_latin1 0xF7 regexp _latin1 '[[:alpha:]]'
|
||||
0
|
||||
select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]';
|
||||
_koi8r 0xF7 regexp _koi8r '[[:alpha:]]'
|
||||
1
|
||||
select _latin1'a' regexp _latin1'A' collate latin1_general_ci;
|
||||
_latin1'a' regexp _latin1'A' collate latin1_general_ci
|
||||
1
|
||||
select _latin1'a' regexp _latin1'A' collate latin1_bin;
|
||||
_latin1'a' regexp _latin1'A' collate latin1_bin
|
||||
0
|
||||
create table t1 (a varchar(40));
|
||||
insert into t1 values ('C1'),('C2'),('R1'),('C3'),('R2'),('R3');
|
||||
prepare stmt1 from 'select a from t1 where a rlike ? order by a';
|
||||
set @a="^C.*";
|
||||
execute stmt1 using @a;
|
||||
a
|
||||
C1
|
||||
C2
|
||||
C3
|
||||
set @a="^R.*";
|
||||
execute stmt1 using @a;
|
||||
a
|
||||
R1
|
||||
R2
|
||||
R3
|
||||
deallocate prepare stmt1;
|
||||
drop table t1;
|
@ -1,251 +0,0 @@
|
||||
drop table if exists t1, test;
|
||||
select extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
2101112000123
|
||||
select extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
101112000123
|
||||
select extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
1112000123
|
||||
select extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
12000123
|
||||
select extract(MICROSECOND FROM "1999-01-02 10:11:12.000123");
|
||||
extract(MICROSECOND FROM "1999-01-02 10:11:12.000123")
|
||||
123
|
||||
select date_format("1997-12-31 23:59:59.000002", "%f");
|
||||
date_format("1997-12-31 23:59:59.000002", "%f")
|
||||
000002
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND)
|
||||
2025-05-23 04:40:39.000001
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND)
|
||||
1999-02-21 17:40:39.000001
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND)
|
||||
1998-01-07 22:41:39.000001
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND)
|
||||
1998-01-01 02:46:40.000001
|
||||
select date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND);
|
||||
date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND)
|
||||
1998-01-01 00:00:00.000001
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND)
|
||||
1997-12-30 22:58:58.999999
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND)
|
||||
1997-12-31 22:58:58.999999
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND)
|
||||
1997-12-31 23:58:58.999999
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND)
|
||||
1997-12-31 23:59:58.999999
|
||||
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND);
|
||||
date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND)
|
||||
1997-12-31 23:59:59.999999
|
||||
select adddate("1997-12-31 23:59:59.000001", 10);
|
||||
adddate("1997-12-31 23:59:59.000001", 10)
|
||||
1998-01-10 23:59:59.000001
|
||||
select subdate("1997-12-31 23:59:59.000001", 10);
|
||||
subdate("1997-12-31 23:59:59.000001", 10)
|
||||
1997-12-21 23:59:59.000001
|
||||
select datediff("1997-12-31 23:59:59.000001","1997-12-30");
|
||||
datediff("1997-12-31 23:59:59.000001","1997-12-30")
|
||||
1
|
||||
select datediff("1997-11-30 23:59:59.000001","1997-12-31");
|
||||
datediff("1997-11-30 23:59:59.000001","1997-12-31")
|
||||
-31
|
||||
SET @@SQL_MODE="ALLOW_INVALID_DATES";
|
||||
select datediff("1997-11-31 23:59:59.000001","1997-12-31");
|
||||
datediff("1997-11-31 23:59:59.000001","1997-12-31")
|
||||
-30
|
||||
SET @@SQL_MODE="";
|
||||
select datediff("1997-11-31 23:59:59.000001","1997-12-31");
|
||||
datediff("1997-11-31 23:59:59.000001","1997-12-31")
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1997-11-31 23:59:59.000001'
|
||||
select datediff("1997-11-30 23:59:59.000001",null);
|
||||
datediff("1997-11-30 23:59:59.000001",null)
|
||||
NULL
|
||||
select weekofyear("1997-11-30 23:59:59.000001");
|
||||
weekofyear("1997-11-30 23:59:59.000001")
|
||||
48
|
||||
select makedate(1997,1);
|
||||
makedate(1997,1)
|
||||
1997-01-01
|
||||
select makedate(1997,0);
|
||||
makedate(1997,0)
|
||||
NULL
|
||||
select makedate(9999,365);
|
||||
makedate(9999,365)
|
||||
9999-12-31
|
||||
select makedate(9999,366);
|
||||
makedate(9999,366)
|
||||
NULL
|
||||
select addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002");
|
||||
addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002")
|
||||
1998-01-02 01:01:01.000001
|
||||
select subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002");
|
||||
subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002")
|
||||
1997-12-30 22:58:57.999999
|
||||
select addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
|
||||
addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
|
||||
NULL
|
||||
select subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
|
||||
subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
|
||||
NULL
|
||||
select subtime("01:00:00.999999", "02:00:00.999998");
|
||||
subtime("01:00:00.999999", "02:00:00.999998")
|
||||
-00:59:59.999999
|
||||
select subtime("02:01:01.999999", "01:01:01.999999");
|
||||
subtime("02:01:01.999999", "01:01:01.999999")
|
||||
01:00:00
|
||||
select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
|
||||
timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002")
|
||||
838:59:59.999999
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '8807:59:59.999999'
|
||||
select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
|
||||
timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002")
|
||||
46:58:57.999999
|
||||
select timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002");
|
||||
timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002")
|
||||
-24:00:00.000001
|
||||
select timediff("1997-12-31 23:59:59.000001","23:59:59.000001");
|
||||
timediff("1997-12-31 23:59:59.000001","23:59:59.000001")
|
||||
NULL
|
||||
select timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001");
|
||||
timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001")
|
||||
-00:00:00.000001
|
||||
select timediff("2005-01-11 15:48:49.999999", "2005-01-11 15:48:50");
|
||||
timediff("2005-01-11 15:48:49.999999", "2005-01-11 15:48:50")
|
||||
-00:00:00.000001
|
||||
select maketime(10,11,12);
|
||||
maketime(10,11,12)
|
||||
10:11:12
|
||||
select maketime(25,11,12);
|
||||
maketime(25,11,12)
|
||||
25:11:12
|
||||
select maketime(-25,11,12);
|
||||
maketime(-25,11,12)
|
||||
-25:11:12
|
||||
select timestamp("2001-12-01", "01:01:01.999999");
|
||||
timestamp("2001-12-01", "01:01:01.999999")
|
||||
2001-12-01 01:01:01.999999
|
||||
select timestamp("2001-13-01", "01:01:01.000001");
|
||||
timestamp("2001-13-01", "01:01:01.000001")
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '2001-13-01'
|
||||
select timestamp("2001-12-01", "25:01:01");
|
||||
timestamp("2001-12-01", "25:01:01")
|
||||
2001-12-02 01:01:01
|
||||
select timestamp("2001-12-01 01:01:01.000100");
|
||||
timestamp("2001-12-01 01:01:01.000100")
|
||||
2001-12-01 01:01:01.000100
|
||||
select timestamp("2001-12-01");
|
||||
timestamp("2001-12-01")
|
||||
2001-12-01 00:00:00
|
||||
select day("1997-12-31 23:59:59.000001");
|
||||
day("1997-12-31 23:59:59.000001")
|
||||
31
|
||||
select date("1997-12-31 23:59:59.000001");
|
||||
date("1997-12-31 23:59:59.000001")
|
||||
1997-12-31
|
||||
select date("1997-13-31 23:59:59.000001");
|
||||
date("1997-13-31 23:59:59.000001")
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1997-13-31 23:59:59.000001'
|
||||
select time("1997-12-31 23:59:59.000001");
|
||||
time("1997-12-31 23:59:59.000001")
|
||||
23:59:59.000001
|
||||
select time("1997-12-31 25:59:59.000001");
|
||||
time("1997-12-31 25:59:59.000001")
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '1997-12-31 25:59:59.000001'
|
||||
select microsecond("1997-12-31 23:59:59.000001");
|
||||
microsecond("1997-12-31 23:59:59.000001")
|
||||
1
|
||||
create table t1
|
||||
select makedate(1997,1) as f1,
|
||||
addtime(cast("1997-12-31 23:59:59.000001" as datetime), "1 1:1:1.000002") as f2,
|
||||
addtime(cast("23:59:59.999999" as time) , "1 1:1:1.000002") as f3,
|
||||
timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002") as f4,
|
||||
timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002") as f5,
|
||||
maketime(10,11,12) as f6,
|
||||
timestamp(cast("2001-12-01" as date), "01:01:01") as f7,
|
||||
date("1997-12-31 23:59:59.000001") as f8,
|
||||
time("1997-12-31 23:59:59.000001") as f9;
|
||||
describe t1;
|
||||
Field Type Null Key Default Extra
|
||||
f1 date YES NULL
|
||||
f2 datetime(6) YES NULL
|
||||
f3 time(6) YES NULL
|
||||
f4 time(6) YES NULL
|
||||
f5 time(6) YES NULL
|
||||
f6 time YES NULL
|
||||
f7 datetime(6) YES NULL
|
||||
f8 date YES NULL
|
||||
f9 time(6) YES NULL
|
||||
select * from t1;
|
||||
f1 f2 f3 f4 f5 f6 f7 f8 f9
|
||||
1997-01-01 1998-01-02 01:01:00.000002 49:01:00.000002 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01.000000 1997-12-31 23:59:59.000001
|
||||
create table test(t1 datetime, t2 time, t3 time, t4 datetime);
|
||||
insert into test values
|
||||
('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
|
||||
('2001-01-01 01:01:01', '-01:01:01', '-23:59:59', "1997-12-31 23:59:59.000001"),
|
||||
('1997-12-31 23:59:59.000001', '-23:59:59', '-01:01:01', '2001-01-01 01:01:01'),
|
||||
('2001-01-01 01:01:01', '01:01:01', '-1 01:01:01', null),
|
||||
('2001-01-01 01:01:01', '-01:01:01', '1 01:01:01', '2001-01-01 01:01:01'),
|
||||
('2001-01-01 01:01:01', null, '-1 01:01:01', null),
|
||||
(null, null, null, null),
|
||||
('2001-01-01 01:01:01', '01:01:01', '1 01:01:01', '2001-01-01 01:01:01');
|
||||
SELECT ADDTIME(t1,t2) As ttt, ADDTIME(t2, t3) As qqq from test;
|
||||
ttt qqq
|
||||
2001-01-01 02:02:02 NULL
|
||||
2001-01-01 00:00:00 -25:01:00
|
||||
1997-12-31 00:00:00 -25:01:00
|
||||
2001-01-01 02:02:02 -24:00:00
|
||||
2001-01-01 00:00:00 24:00:00
|
||||
NULL NULL
|
||||
NULL NULL
|
||||
2001-01-01 02:02:02 26:02:02
|
||||
SELECT TIMEDIFF(t1, t4) As ttt, TIMEDIFF(t2, t3) As qqq,
|
||||
TIMEDIFF(t3, t2) As eee, TIMEDIFF(t2, t4) As rrr from test;
|
||||
ttt qqq eee rrr
|
||||
-744:00:00 NULL NULL NULL
|
||||
838:59:59 22:58:58 -22:58:58 NULL
|
||||
-838:59:59 -22:58:58 22:58:58 NULL
|
||||
NULL 26:02:02 -26:02:02 NULL
|
||||
00:00:00 -26:02:02 26:02:02 NULL
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
00:00:00 -24:00:00 24:00:00 NULL
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '26305:01:02'
|
||||
Warning 1292 Truncated incorrect time value: '-26305:01:02'
|
||||
drop table t1, test;
|
||||
select addtime("-01:01:01.01", "-23:59:59.1") as a;
|
||||
a
|
||||
-25:01:00.110000
|
||||
select microsecond("1997-12-31 23:59:59.01") as a;
|
||||
a
|
||||
10000
|
||||
select microsecond(19971231235959.01) as a;
|
||||
a
|
||||
10000
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect time value: '19971231235959.01'
|
||||
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
|
||||
a
|
||||
1997-12-31 00:00:10.090000
|
||||
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f");
|
||||
str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f")
|
||||
2003-01-02 10:11:12.001200
|
@ -1,75 +0,0 @@
|
||||
select interval(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
|
||||
interval(55,10,20,30,40,50,60,70,80,90,100) interval(3,1,1+1,1+1+1+1) field("IBM","NCA","ICL","SUN","IBM","DIGITAL") field("A","B","C") elt(2,"ONE","TWO","THREE") interval(0,1,2,3,4) elt(1,1,2,3)|0 elt(1,1.1,1.2,1.3)+0
|
||||
5 2 4 0 TWO 0 1 1.1
|
||||
explain extended select INTERVAL(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select interval((55,10,20,30,40,50,60,70,80,90,100)) AS `INTERVAL(55,10,20,30,40,50,60,70,80,90,100)`,interval((3,1,(1 + 1),(((1 + 1) + 1) + 1))) AS `interval(3,1,1+1,1+1+1+1)`,field('IBM','NCA','ICL','SUN','IBM','DIGITAL') AS `field("IBM","NCA","ICL","SUN","IBM","DIGITAL")`,field('A','B','C') AS `field("A","B","C")`,elt(2,'ONE','TWO','THREE') AS `elt(2,"ONE","TWO","THREE")`,interval((0,1,2,3,4)) AS `interval(0,1,2,3,4)`,(elt(1,1,2,3) | 0) AS `elt(1,1,2,3)|0`,(elt(1,1.1,1.2,1.3) + 0) AS `elt(1,1.1,1.2,1.3)+0`
|
||||
SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56);
|
||||
INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56)
|
||||
1
|
||||
SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56, 77);
|
||||
INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56, 77)
|
||||
1
|
||||
select find_in_set("b","a,b,c"),find_in_set("c","a,b,c"),find_in_set("dd","a,bbb,dd"),find_in_set("bbb","a,bbb,dd");
|
||||
find_in_set("b","a,b,c") find_in_set("c","a,b,c") find_in_set("dd","a,bbb,dd") find_in_set("bbb","a,bbb,dd")
|
||||
2 3 3 2
|
||||
select find_in_set("d","a,b,c"),find_in_set("dd","a,bbb,d"),find_in_set("bb","a,bbb,dd");
|
||||
find_in_set("d","a,b,c") find_in_set("dd","a,bbb,d") find_in_set("bb","a,bbb,dd")
|
||||
0 0 0
|
||||
select make_set(0,'a','b','c'),make_set(-1,'a','b','c'),make_set(1,'a','b','c'),make_set(2,'a','b','c'),make_set(1+2,concat('a','b'),'c');
|
||||
make_set(0,'a','b','c') make_set(-1,'a','b','c') make_set(1,'a','b','c') make_set(2,'a','b','c') make_set(1+2,concat('a','b'),'c')
|
||||
a,b,c a b ab,c
|
||||
select make_set(NULL,'a','b','c'),make_set(1|4,'a',NULL,'c'),make_set(1+2,'a',NULL,'c');
|
||||
make_set(NULL,'a','b','c') make_set(1|4,'a',NULL,'c') make_set(1+2,'a',NULL,'c')
|
||||
NULL a,c a
|
||||
select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N","");
|
||||
export_set(9,"Y","N","-",5) export_set(9,"Y","N") export_set(9,"Y","N","")
|
||||
Y-N-N-Y-N Y,N,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N YNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
|
||||
select elt(2,1),field(NULL,"a","b","c");
|
||||
elt(2,1) field(NULL,"a","b","c")
|
||||
NULL 0
|
||||
select field("b","a",NULL),field(1,0,NULL)+0,field(1.0,0.0,NULL)+0.0,field(1.0e1,0.0e1,NULL)+0.0e1;
|
||||
field("b","a",NULL) field(1,0,NULL)+0 field(1.0,0.0,NULL)+0.0 field(1.0e1,0.0e1,NULL)+0.0e1
|
||||
0 0 0.0 0
|
||||
select field(NULL,"a",NULL),field(NULL,0,NULL)+0,field(NULL,0.0,NULL)+0.0,field(NULL,0.0e1,NULL)+0.0e1;
|
||||
field(NULL,"a",NULL) field(NULL,0,NULL)+0 field(NULL,0.0,NULL)+0.0 field(NULL,0.0e1,NULL)+0.0e1
|
||||
0 0 0.0 0
|
||||
select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
|
||||
find_in_set("","a,b,c") find_in_set("","a,b,c,") find_in_set("",",a,b,c")
|
||||
0 4 1
|
||||
select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
|
||||
find_in_set("abc","abc") find_in_set("ab","abc") find_in_set("abcd","abc")
|
||||
1 0 0
|
||||
select interval(null, 1, 10, 100);
|
||||
interval(null, 1, 10, 100)
|
||||
-1
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (id int(10) not null unique);
|
||||
create table t2 (id int(10) not null primary key, val int(10) not null);
|
||||
insert into t1 values (1),(2),(4);
|
||||
insert into t2 values (1,1),(2,1),(3,1),(4,2);
|
||||
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
|
||||
id elt(two.val,'one','two')
|
||||
1 one
|
||||
2 one
|
||||
4 two
|
||||
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
|
||||
id elt(two.val,'one','two')
|
||||
1 one
|
||||
2 one
|
||||
4 two
|
||||
drop table t1,t2;
|
||||
select find_in_set(binary 'a',binary 'A,B,C');
|
||||
find_in_set(binary 'a',binary 'A,B,C')
|
||||
0
|
||||
select find_in_set('a',binary 'A,B,C');
|
||||
find_in_set('a',binary 'A,B,C')
|
||||
0
|
||||
select find_in_set(binary 'a', 'A,B,C');
|
||||
find_in_set(binary 'a', 'A,B,C')
|
||||
0
|
||||
select find_in_set('1','3,1,');
|
||||
find_in_set('1','3,1,')
|
||||
2
|
File diff suppressed because it is too large
Load Diff
@ -1,97 +0,0 @@
|
||||
select database();
|
||||
database()
|
||||
test
|
||||
select charset(database());
|
||||
charset(database())
|
||||
utf8
|
||||
select database() = "test";
|
||||
database() = "test"
|
||||
1
|
||||
select database() = _utf8"test";
|
||||
database() = _utf8"test"
|
||||
1
|
||||
select database() = _latin1"test";
|
||||
database() = _latin1"test"
|
||||
1
|
||||
select user() like "%@%";
|
||||
user() like "%@%"
|
||||
1
|
||||
select user() like _utf8"%@%";
|
||||
user() like _utf8"%@%"
|
||||
1
|
||||
select user() like _latin1"%@%";
|
||||
user() like _latin1"%@%"
|
||||
1
|
||||
select charset(user());
|
||||
charset(user())
|
||||
utf8
|
||||
select version()>="3.23.29";
|
||||
version()>="3.23.29"
|
||||
1
|
||||
select version()>=_utf8"3.23.29";
|
||||
version()>=_utf8"3.23.29"
|
||||
1
|
||||
select version()>=_latin1"3.23.29";
|
||||
version()>=_latin1"3.23.29"
|
||||
1
|
||||
select charset(version());
|
||||
charset(version())
|
||||
utf8
|
||||
explain extended select database(), user();
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select database() AS `database()`,user() AS `user()`
|
||||
create table t1 (version char(60)) select database(), user(), version() as 'version';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`database()` varchar(34) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`user()` varchar(77) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`version` char(60) DEFAULT NULL
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
select charset(charset(_utf8'a')), charset(collation(_utf8'a'));
|
||||
charset(charset(_utf8'a')) charset(collation(_utf8'a'))
|
||||
utf8 utf8
|
||||
select collation(charset(_utf8'a')), collation(collation(_utf8'a'));
|
||||
collation(charset(_utf8'a')) collation(collation(_utf8'a'))
|
||||
utf8_general_ci utf8_general_ci
|
||||
create table t1 select charset(_utf8'a'), collation(_utf8'a');
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`charset(_utf8'a')` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`collation(_utf8'a')` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT ''
|
||||
) ENGINE=PBXT DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
select TRUE,FALSE,NULL;
|
||||
TRUE FALSE NULL
|
||||
1 0 NULL
|
||||
create table t1 (c1 char(5)) character set=latin1;
|
||||
insert into t1 values('row 1');
|
||||
insert into t1 values('row 2');
|
||||
insert into t1 values('row 3');
|
||||
select concat(user(), '--', c1) from t1;
|
||||
concat(user(), '--', c1)
|
||||
root@localhost--row 1
|
||||
root@localhost--row 2
|
||||
root@localhost--row 3
|
||||
select concat(database(), '--', c1) from t1;
|
||||
concat(database(), '--', c1)
|
||||
test--row 1
|
||||
test--row 2
|
||||
test--row 3
|
||||
drop table t1;
|
||||
create table t1 (a char(10)) character set latin1;
|
||||
select * from t1 where a=version();
|
||||
a
|
||||
select * from t1 where a=database();
|
||||
a
|
||||
select * from t1 where a=user();
|
||||
a
|
||||
insert into t1 values ('a');
|
||||
select left(concat(a,version()),1) from t1;
|
||||
left(concat(a,version()),1)
|
||||
a
|
||||
drop table t1;
|
@ -1,13 +0,0 @@
|
||||
drop table if exists t1;
|
||||
set time_zone="+03:00";
|
||||
create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null,
|
||||
Jahr smallint not null, index(Tag), index(Monat), index(Jahr) );
|
||||
insert into t1 values ("09:26:00",16,9,1998),("09:26:00",16,9,1998);
|
||||
SELECT CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit) AS Date,
|
||||
UNIX_TIMESTAMP(CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit)) AS Unix
|
||||
FROM t1;
|
||||
Date Unix
|
||||
1998-9-16 09:26:00 905927160.000000
|
||||
1998-9-16 09:26:00 905927160.000000
|
||||
drop table t1;
|
||||
set time_zone= @@global.time_zone;
|
@ -1,20 +0,0 @@
|
||||
drop table if exists t1;
|
||||
CREATE TABLE t1 (
|
||||
kodoboru varchar(10) default NULL,
|
||||
obor tinytext,
|
||||
aobor tinytext,
|
||||
UNIQUE INDEX kodoboru (kodoboru),
|
||||
FULLTEXT KEY obor (obor),
|
||||
FULLTEXT KEY aobor (aobor)
|
||||
) engine=myisam;
|
||||
INSERT INTO t1 VALUES ('0101000000','aaa','AAA');
|
||||
INSERT INTO t1 VALUES ('0102000000','bbb','BBB');
|
||||
INSERT INTO t1 VALUES ('0103000000','ccc','CCC');
|
||||
INSERT INTO t1 VALUES ('0104000000','xxx','XXX');
|
||||
select * from t1;
|
||||
kodoboru obor aobor
|
||||
0101000000 aaa AAA
|
||||
0102000000 bbb BBB
|
||||
0103000000 ccc CCC
|
||||
0104000000 xxx XXX
|
||||
drop table t1;
|
File diff suppressed because it is too large
Load Diff
@ -1,212 +0,0 @@
|
||||
drop table if exists test.t1,mysqltest.t1,mysqltest.t2;
|
||||
drop database if exists mysqltest;
|
||||
set GLOBAL query_cache_size=1355776;
|
||||
reset query cache;
|
||||
flush status;
|
||||
show grants for current_user;
|
||||
Grants for root@localhost
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
|
||||
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
|
||||
show grants;
|
||||
Grants for root@localhost
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
|
||||
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
|
||||
create database if not exists mysqltest;
|
||||
create table mysqltest.t1 (a int,b int,c int);
|
||||
create table mysqltest.t2 (a int,b int,c int);
|
||||
insert into mysqltest.t1 values (1,1,1),(2,2,2);
|
||||
insert into mysqltest.t2 values (3,3,3);
|
||||
create table test.t1 (a char (10)) engine=myisam;
|
||||
insert into test.t1 values ("test.t1");
|
||||
select * from t1;
|
||||
a
|
||||
test.t1
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 1
|
||||
2 2 2
|
||||
select a from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select c from t1;
|
||||
c
|
||||
1
|
||||
2
|
||||
select * from t2;
|
||||
a b c
|
||||
3 3 3
|
||||
select * from mysqltest.t1,test.t1;
|
||||
a b c a
|
||||
1 1 1 test.t1
|
||||
2 2 2 test.t1
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits%";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
grant SELECT on mysqltest.* to mysqltest_1@localhost;
|
||||
grant SELECT on mysqltest.t1 to mysqltest_2@localhost;
|
||||
grant SELECT on test.t1 to mysqltest_2@localhost;
|
||||
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
|
||||
show grants for current_user();
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
||||
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 0
|
||||
select "user1";
|
||||
user1
|
||||
user1
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 1
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 1
|
||||
2 2 2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 1
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 1
|
||||
select a from t1 ;
|
||||
a
|
||||
1
|
||||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 1
|
||||
select c from t1;
|
||||
c
|
||||
1
|
||||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 3
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 1
|
||||
show grants for current_user();
|
||||
Grants for @localhost
|
||||
GRANT USAGE ON *.* TO ''@'localhost'
|
||||
select "user2";
|
||||
user2
|
||||
user2
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 1
|
||||
2 2 2
|
||||
select a from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select c from t1;
|
||||
c
|
||||
1
|
||||
2
|
||||
select * from mysqltest.t1,test.t1;
|
||||
a b c a
|
||||
1 1 1 test.t1
|
||||
2 2 2 test.t1
|
||||
select * from t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 7
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 2
|
||||
select "user3";
|
||||
user3
|
||||
user3
|
||||
select * from t1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't1'
|
||||
select a from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select c from t1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'
|
||||
select * from t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't2'
|
||||
select mysqltest.t1.c from test.t1,mysqltest.t1;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 7
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 4
|
||||
select "user4";
|
||||
user4
|
||||
user4
|
||||
show grants;
|
||||
Grants for mysqltest_1@localhost
|
||||
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
||||
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
|
||||
select a from t1;
|
||||
ERROR 3D000: No database selected
|
||||
select * from mysqltest.t1,test.t1;
|
||||
a b c a
|
||||
1 1 1 test.t1
|
||||
2 2 2 test.t1
|
||||
select a from mysqltest.t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select a from mysqltest.t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 8
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 8
|
||||
show status like "Qcache_not_cached";
|
||||
Variable_name Value
|
||||
Qcache_not_cached 5
|
||||
set names binary;
|
||||
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||
delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||
delete from mysql.columns_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
|
||||
flush privileges;
|
||||
drop table test.t1,mysqltest.t1,mysqltest.t2;
|
||||
drop database mysqltest;
|
||||
set GLOBAL query_cache_size=default;
|
@ -1,662 +0,0 @@
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7;
|
||||
set @save_join_cache_level=@@join_cache_level;
|
||||
set join_cache_level=1;
|
||||
create table t1 (
|
||||
c11 integer,c12 integer,c13 integer,c14 integer,c15 integer,c16 integer,
|
||||
primary key (c11)
|
||||
);
|
||||
create table t2 (
|
||||
c21 integer,c22 integer,c23 integer,c24 integer,c25 integer,c26 integer
|
||||
);
|
||||
create table t3 (
|
||||
c31 integer,c32 integer,c33 integer,c34 integer,c35 integer,c36 integer,
|
||||
primary key (c31)
|
||||
);
|
||||
create table t4 (
|
||||
c41 integer,c42 integer,c43 integer,c44 integer,c45 integer,c46 integer
|
||||
);
|
||||
create table t5 (
|
||||
c51 integer,c52 integer,c53 integer,c54 integer,c55 integer,c56 integer,
|
||||
primary key (c51)
|
||||
);
|
||||
create table t6 (
|
||||
c61 integer,c62 integer,c63 integer,c64 integer,c65 integer,c66 integer
|
||||
);
|
||||
create table t7 (
|
||||
c71 integer,c72 integer,c73 integer,c74 integer,c75 integer,c76 integer,
|
||||
primary key (c71)
|
||||
);
|
||||
insert into t1 values (1,2,3,4,5,6);
|
||||
insert into t1 values (2,2,3,4,5,6);
|
||||
insert into t1 values (3,2,3,4,5,6);
|
||||
insert into t2 values (1,2,3,4,5,6);
|
||||
insert into t2 values (2,2,3,4,5,6);
|
||||
insert into t2 values (3,2,3,4,5,6);
|
||||
insert into t2 values (4,2,3,4,5,6);
|
||||
insert into t2 values (5,2,3,4,5,6);
|
||||
insert into t2 values (6,2,3,4,5,6);
|
||||
insert into t3 values (1,2,3,4,5,6);
|
||||
insert into t3 values (2,2,3,4,5,6);
|
||||
insert into t3 values (3,2,3,4,5,6);
|
||||
insert into t3 values (4,2,3,4,5,6);
|
||||
insert into t3 values (5,2,3,4,5,6);
|
||||
insert into t3 values (6,2,3,4,5,6);
|
||||
insert into t3 values (7,2,3,4,5,6);
|
||||
insert into t3 values (8,2,3,4,5,6);
|
||||
insert into t3 values (9,2,3,4,5,6);
|
||||
insert into t4 values (1,2,3,4,5,6);
|
||||
insert into t4 values (2,2,3,4,5,6);
|
||||
insert into t4 values (3,2,3,4,5,6);
|
||||
insert into t4 values (4,2,3,4,5,6);
|
||||
insert into t4 values (5,2,3,4,5,6);
|
||||
insert into t4 values (6,2,3,4,5,6);
|
||||
insert into t4 values (7,2,3,4,5,6);
|
||||
insert into t4 values (8,2,3,4,5,6);
|
||||
insert into t4 values (9,2,3,4,5,6);
|
||||
insert into t4 values (10,2,3,4,5,6);
|
||||
insert into t4 values (11,2,3,4,5,6);
|
||||
insert into t4 values (12,2,3,4,5,6);
|
||||
insert into t5 values (1,2,3,4,5,6);
|
||||
insert into t5 values (2,2,3,4,5,6);
|
||||
insert into t5 values (3,2,3,4,5,6);
|
||||
insert into t5 values (4,2,3,4,5,6);
|
||||
insert into t5 values (5,2,3,4,5,6);
|
||||
insert into t5 values (6,2,3,4,5,6);
|
||||
insert into t5 values (7,2,3,4,5,6);
|
||||
insert into t5 values (8,2,3,4,5,6);
|
||||
insert into t5 values (9,2,3,4,5,6);
|
||||
insert into t5 values (10,2,3,4,5,6);
|
||||
insert into t5 values (11,2,3,4,5,6);
|
||||
insert into t5 values (12,2,3,4,5,6);
|
||||
insert into t5 values (13,2,3,4,5,6);
|
||||
insert into t5 values (14,2,3,4,5,6);
|
||||
insert into t5 values (15,2,3,4,5,6);
|
||||
insert into t6 values (1,2,3,4,5,6);
|
||||
insert into t6 values (2,2,3,4,5,6);
|
||||
insert into t6 values (3,2,3,4,5,6);
|
||||
insert into t6 values (4,2,3,4,5,6);
|
||||
insert into t6 values (5,2,3,4,5,6);
|
||||
insert into t6 values (6,2,3,4,5,6);
|
||||
insert into t6 values (7,2,3,4,5,6);
|
||||
insert into t6 values (8,2,3,4,5,6);
|
||||
insert into t6 values (9,2,3,4,5,6);
|
||||
insert into t6 values (10,2,3,4,5,6);
|
||||
insert into t6 values (11,2,3,4,5,6);
|
||||
insert into t6 values (12,2,3,4,5,6);
|
||||
insert into t6 values (13,2,3,4,5,6);
|
||||
insert into t6 values (14,2,3,4,5,6);
|
||||
insert into t6 values (15,2,3,4,5,6);
|
||||
insert into t6 values (16,2,3,4,5,6);
|
||||
insert into t6 values (17,2,3,4,5,6);
|
||||
insert into t6 values (18,2,3,4,5,6);
|
||||
insert into t7 values (1,2,3,4,5,6);
|
||||
insert into t7 values (2,2,3,4,5,6);
|
||||
insert into t7 values (3,2,3,4,5,6);
|
||||
insert into t7 values (4,2,3,4,5,6);
|
||||
insert into t7 values (5,2,3,4,5,6);
|
||||
insert into t7 values (6,2,3,4,5,6);
|
||||
insert into t7 values (7,2,3,4,5,6);
|
||||
insert into t7 values (8,2,3,4,5,6);
|
||||
insert into t7 values (9,2,3,4,5,6);
|
||||
insert into t7 values (10,2,3,4,5,6);
|
||||
insert into t7 values (11,2,3,4,5,6);
|
||||
insert into t7 values (12,2,3,4,5,6);
|
||||
insert into t7 values (13,2,3,4,5,6);
|
||||
insert into t7 values (14,2,3,4,5,6);
|
||||
insert into t7 values (15,2,3,4,5,6);
|
||||
insert into t7 values (16,2,3,4,5,6);
|
||||
insert into t7 values (17,2,3,4,5,6);
|
||||
insert into t7 values (18,2,3,4,5,6);
|
||||
insert into t7 values (19,2,3,4,5,6);
|
||||
insert into t7 values (20,2,3,4,5,6);
|
||||
insert into t7 values (21,2,3,4,5,6);
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
62
|
||||
select @@optimizer_prune_level;
|
||||
@@optimizer_prune_level
|
||||
1
|
||||
set optimizer_search_depth=63;
|
||||
Warnings:
|
||||
Warning 1287 'optimizer-search-depth=63' is deprecated and will be removed in a future release. Please use a search depth less than 63 instead
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
63
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 822.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 795.625316
|
||||
set optimizer_prune_level=0;
|
||||
select @@optimizer_prune_level;
|
||||
@@optimizer_prune_level
|
||||
0
|
||||
set optimizer_search_depth=0;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
0
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1372.225316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1372.225316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 363.346368
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 363.346368
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 363.346368
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 363.346368
|
||||
set optimizer_search_depth=1;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
1
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1694.425316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1694.425316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
set optimizer_search_depth=62;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
62
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1372.225316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1372.225316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 363.346368
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 363.346368
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 363.346368
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 363.346368
|
||||
set optimizer_prune_level=1;
|
||||
select @@optimizer_prune_level;
|
||||
@@optimizer_prune_level
|
||||
1
|
||||
set optimizer_search_depth=0;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
0
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1694.425316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1694.425316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
set optimizer_search_depth=1;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
1
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1694.425316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1694.425316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
set optimizer_search_depth=62;
|
||||
select @@optimizer_search_depth;
|
||||
@@optimizer_search_depth
|
||||
62
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1694.425316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 1694.425316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
|
||||
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1
|
||||
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
|
||||
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
show status like 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 844.825316
|
||||
drop table t1,t2,t3,t4,t5,t6,t7;
|
||||
set join_cache_level=@save_join_cache_level;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,407 +0,0 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (a int);
|
||||
select count(a) as b from t1 where a=0 having b > 0;
|
||||
b
|
||||
insert into t1 values (null);
|
||||
select count(a) as b from t1 where a=0 having b > 0;
|
||||
b
|
||||
select count(a) as b from t1 where a=0 having b >=0;
|
||||
b
|
||||
0
|
||||
explain extended select count(a) as b from t1 where a=0 having b >=0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where (`test`.`t1`.`a` = 0) having (`b` >= 0)
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
raw_id int(10) NOT NULL default '0',
|
||||
chr_start int(10) NOT NULL default '0',
|
||||
chr_end int(10) NOT NULL default '0',
|
||||
raw_start int(10) NOT NULL default '0',
|
||||
raw_end int(10) NOT NULL default '0',
|
||||
raw_ori int(2) NOT NULL default '0'
|
||||
);
|
||||
INSERT INTO t1 VALUES (469713,1,164123,1,164123,1),(317330,164124,317193,101,153170,1),(469434,317194,375620,101,58527,1),(591816,375621,484273,1,108653,1),(591807,484274,534671,91,50488,1),(318885,534672,649362,101,114791,1),(318728,649363,775520,102,126259,1),(336829,775521,813997,101,38577,1),(317740,813998,953227,101,139330,1),(1,813998,953227,101,139330,1);
|
||||
CREATE TABLE t2 (
|
||||
id int(10) unsigned NOT NULL default '0',
|
||||
contig_id int(10) unsigned NOT NULL default '0',
|
||||
seq_start int(10) NOT NULL default '0',
|
||||
seq_end int(10) NOT NULL default '0',
|
||||
strand tinyint(2) NOT NULL default '0',
|
||||
KEY id (id)
|
||||
);
|
||||
INSERT INTO t2 VALUES (133195,469713,61327,61384,1),(133196,469713,64113,64387,1),(133197,1,1,1,0),(133197,1,1,1,-2);
|
||||
SELECT e.id,
|
||||
MIN( IF(sgp.raw_ori=1,
|
||||
(e.seq_start+sgp.chr_start-sgp.raw_start),
|
||||
(sgp.chr_start+sgp.raw_end-e.seq_end))) as start,
|
||||
MAX( IF(sgp.raw_ori=1,
|
||||
(e.seq_end+sgp.chr_start-sgp.raw_start),
|
||||
(sgp.chr_start+sgp.raw_end-e.seq_start))) as end,
|
||||
AVG(IF (sgp.raw_ori=1,e.strand,(-e.strand))) as chr_strand
|
||||
FROM t1 sgp,
|
||||
t2 e
|
||||
WHERE sgp.raw_id=e.contig_id
|
||||
GROUP BY e.id
|
||||
HAVING chr_strand= -1 and end >= 0
|
||||
AND start <= 999660;
|
||||
id start end chr_strand
|
||||
133197 813898 813898 -1.0000
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (Fld1 int(11) default NULL,Fld2 int(11) default NULL);
|
||||
INSERT INTO t1 VALUES (1,10),(1,20),(2,NULL),(2,NULL),(3,50);
|
||||
select Fld1, max(Fld2) as q from t1 group by Fld1 having q is not null;
|
||||
Fld1 q
|
||||
1 20
|
||||
3 50
|
||||
select Fld1, max(Fld2) from t1 group by Fld1 having max(Fld2) is not null;
|
||||
Fld1 max(Fld2)
|
||||
1 20
|
||||
3 50
|
||||
select Fld1, max(Fld2) from t1 group by Fld1 having avg(Fld2) is not null;
|
||||
Fld1 max(Fld2)
|
||||
1 20
|
||||
3 50
|
||||
select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null;
|
||||
Fld1 max(Fld2)
|
||||
1 20
|
||||
3 50
|
||||
select Fld1, max(Fld2) from t1 group by Fld1 having variance(Fld2) is not null;
|
||||
Fld1 max(Fld2)
|
||||
1 20
|
||||
3 50
|
||||
drop table t1;
|
||||
create table t1 (id int not null, qty int not null);
|
||||
insert into t1 values (1,2),(1,3),(2,4),(2,5);
|
||||
select id, sum(qty) as sqty from t1 group by id having sqty>2;
|
||||
id sqty
|
||||
1 5
|
||||
2 9
|
||||
select sum(qty) as sqty from t1 group by id having count(id) > 0;
|
||||
sqty
|
||||
5
|
||||
9
|
||||
select sum(qty) as sqty from t1 group by id having count(distinct id) > 0;
|
||||
sqty
|
||||
5
|
||||
9
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
`id` bigint(20) NOT NULL default '0',
|
||||
`description` text
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
`id` bigint(20) NOT NULL default '0',
|
||||
`description` varchar(20)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1, 'test');
|
||||
INSERT INTO t2 VALUES (1, 'test');
|
||||
CREATE TABLE t3 (
|
||||
`id` bigint(20) NOT NULL default '0',
|
||||
`order_id` bigint(20) NOT NULL default '0'
|
||||
) ENGINE=MyISAM;
|
||||
select
|
||||
a.id, a.description,
|
||||
count(b.id) as c
|
||||
from t1 a left join t3 b on a.id=b.order_id
|
||||
group by a.id, a.description
|
||||
having (a.description is not null) and (c=0);
|
||||
id description c
|
||||
1 test 0
|
||||
select
|
||||
a.*,
|
||||
count(b.id) as c
|
||||
from t2 a left join t3 b on a.id=b.order_id
|
||||
group by a.id, a.description
|
||||
having (a.description is not null) and (c=0);
|
||||
id description c
|
||||
1 test 0
|
||||
INSERT INTO t1 VALUES (2, 'test2');
|
||||
select
|
||||
a.id, a.description,
|
||||
count(b.id) as c
|
||||
from t1 a left join t3 b on a.id=b.order_id
|
||||
group by a.id, a.description
|
||||
having (a.description is not null) and (c=0);
|
||||
id description c
|
||||
1 test 0
|
||||
2 test2 0
|
||||
drop table t1,t2,t3;
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (3), (4), (1), (3), (1);
|
||||
SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a)>0;
|
||||
SUM(a)
|
||||
2
|
||||
6
|
||||
4
|
||||
SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a);
|
||||
SUM(a)
|
||||
2
|
||||
6
|
||||
4
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (1), (2), (1), (3), (2), (1);
|
||||
SELECT a FROM t1 GROUP BY a HAVING a > 1;
|
||||
a
|
||||
2
|
||||
3
|
||||
SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
|
||||
a
|
||||
SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
|
||||
x a
|
||||
EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
DROP table t1;
|
||||
create table t1 (col1 int, col2 varchar(5), col_t1 int);
|
||||
create table t2 (col1 int, col2 varchar(5), col_t2 int);
|
||||
create table t3 (col1 int, col2 varchar(5), col_t3 int);
|
||||
insert into t1 values(10,'hello',10);
|
||||
insert into t1 values(20,'hello',20);
|
||||
insert into t1 values(30,'hello',30);
|
||||
insert into t1 values(10,'bye',10);
|
||||
insert into t1 values(10,'sam',10);
|
||||
insert into t1 values(10,'bob',10);
|
||||
insert into t2 select * from t1;
|
||||
insert into t3 select * from t1;
|
||||
select count(*) from t1 group by col1 having col1 = 10;
|
||||
count(*)
|
||||
4
|
||||
select count(*) as count_col1 from t1 group by col1 having col1 = 10;
|
||||
count_col1
|
||||
4
|
||||
select count(*) as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
|
||||
count_col1
|
||||
4
|
||||
select count(*) from t1 group by col2 having col2 = 'hello';
|
||||
count(*)
|
||||
3
|
||||
select count(*) from t1 group by col2 having col1 = 10;
|
||||
ERROR 42S22: Unknown column 'col1' in 'having clause'
|
||||
select col1 as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
|
||||
count_col1
|
||||
10
|
||||
select col1 as count_col1 from t1 as tmp1 group by col1 having count_col1 = 10;
|
||||
count_col1
|
||||
10
|
||||
select col1 as count_col1 from t1 as tmp1 group by count_col1 having col1 = 10;
|
||||
count_col1
|
||||
10
|
||||
select col1 as count_col1 from t1 as tmp1 group by count_col1 having count_col1 = 10;
|
||||
count_col1
|
||||
10
|
||||
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col1 = 10;
|
||||
count_col1 col2
|
||||
10 bob
|
||||
10 bye
|
||||
10 hello
|
||||
10 sam
|
||||
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having count_col1 = 10;
|
||||
count_col1 col2
|
||||
10 bob
|
||||
10 bye
|
||||
10 hello
|
||||
10 sam
|
||||
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col2 = 'hello';
|
||||
count_col1 col2
|
||||
10 hello
|
||||
20 hello
|
||||
30 hello
|
||||
select col1 as count_col1,col2 as group_col2 from t1 as tmp1 group by col1,col2 having group_col2 = 'hello';
|
||||
count_col1 group_col2
|
||||
10 hello
|
||||
20 hello
|
||||
30 hello
|
||||
select sum(col1) as co12 from t1 group by col2 having col2 10;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '10' at line 1
|
||||
select sum(col1) as co2, count(col2) as cc from t1 group by col1 having col1 =10;
|
||||
co2 cc
|
||||
40 4
|
||||
select t2.col2 from t2 group by t2.col1, t2.col2 having t1.col1 <= 10;
|
||||
ERROR 42S22: Unknown column 't1.col1' in 'having clause'
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having t2.col1 <= 10);
|
||||
col1
|
||||
10
|
||||
20
|
||||
30
|
||||
10
|
||||
10
|
||||
10
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2
|
||||
having t2.col1 <=
|
||||
(select min(t3.col1) from t3));
|
||||
col1
|
||||
10
|
||||
20
|
||||
30
|
||||
10
|
||||
10
|
||||
10
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having t1.col1 <= 10);
|
||||
col1
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
select t1.col1 as tmp_col from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having tmp_col <= 10);
|
||||
tmp_col
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having col_t1 <= 10);
|
||||
col1
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
select sum(col1) from t1
|
||||
group by col_t1
|
||||
having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1);
|
||||
sum(col1)
|
||||
40
|
||||
20
|
||||
30
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having col_t1 <= 10)
|
||||
having col_t1 <= 20;
|
||||
ERROR 42S22: Unknown column 'col_t1' in 'having clause'
|
||||
select t1.col1 from t1
|
||||
where t1.col2 in
|
||||
(select t2.col2 from t2
|
||||
group by t2.col1, t2.col2 having col_t1 <= 10)
|
||||
group by col_t1
|
||||
having col_t1 <= 20;
|
||||
col1
|
||||
10
|
||||
select col_t1, sum(col1) from t1
|
||||
group by col_t1
|
||||
having col_t1 > 10 and
|
||||
exists (select sum(t2.col1) from t2
|
||||
group by t2.col2 having t2.col2 > 'b');
|
||||
col_t1 sum(col1)
|
||||
20 20
|
||||
30 30
|
||||
select sum(col1) from t1
|
||||
group by col_t1
|
||||
having col_t1 in (select sum(t2.col1) from t2
|
||||
group by t2.col2, t2.col1 having t2.col1 = t1.col1);
|
||||
ERROR 42S22: Unknown column 't1.col1' in 'having clause'
|
||||
select sum(col1) from t1
|
||||
group by col_t1
|
||||
having col_t1 in (select sum(t2.col1) from t2
|
||||
group by t2.col2, t2.col1 having t2.col1 = col_t1);
|
||||
sum(col1)
|
||||
40
|
||||
20
|
||||
30
|
||||
select t1.col1, t2.col1 from t1, t2 where t1.col1 = t2.col1
|
||||
group by t1.col1, t2.col1 having col1 = 2;
|
||||
ERROR 23000: Column 'col1' in having clause is ambiguous
|
||||
select t1.col1*10+t2.col1 from t1,t2 where t1.col1=t2.col1
|
||||
group by t1.col1, t2.col1 having col1 = 2;
|
||||
ERROR 23000: Column 'col1' in having clause is ambiguous
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (s1 int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
select count(*) from t1 group by s1 having s1 is null;
|
||||
count(*)
|
||||
select s1*0 as s1 from t1 group by s1 having s1 <> 0;
|
||||
s1
|
||||
0
|
||||
0
|
||||
0
|
||||
Warnings:
|
||||
Warning 1052 Column 's1' in group statement is ambiguous
|
||||
Warning 1052 Column 's1' in having clause is ambiguous
|
||||
select s1*0 from t1 group by s1 having s1 = 0;
|
||||
s1*0
|
||||
select s1 from t1 group by 1 having 1 = 0;
|
||||
s1
|
||||
select count(s1) from t1 group by s1 having count(1+1)=2;
|
||||
count(s1)
|
||||
select count(s1) from t1 group by s1 having s1*0=0;
|
||||
count(s1)
|
||||
1
|
||||
1
|
||||
1
|
||||
select * from t1 a, t1 b group by a.s1 having s1 is null;
|
||||
ERROR 23000: Column 's1' in having clause is ambiguous
|
||||
drop table t1;
|
||||
create table t1 (s1 char character set latin1 collate latin1_german1_ci);
|
||||
insert into t1 values ('ü'),('y');
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 's1' at row 1
|
||||
select s1,count(s1) from t1
|
||||
group by s1 collate latin1_swedish_ci having s1 = 'y';
|
||||
s1 count(s1)
|
||||
y 1
|
||||
drop table t1;
|
||||
DROP SCHEMA IF EXISTS HU;
|
||||
CREATE SCHEMA HU ;
|
||||
USE HU ;
|
||||
CREATE TABLE STAFF
|
||||
(EMPNUM CHAR(3) NOT NULL UNIQUE,
|
||||
EMPNAME CHAR(20),
|
||||
GRADE DECIMAL(4),
|
||||
CITY CHAR(15));
|
||||
CREATE TABLE PROJ
|
||||
(PNUM CHAR(3) NOT NULL UNIQUE,
|
||||
PNAME CHAR(20),
|
||||
PTYPE CHAR(6),
|
||||
BUDGET DECIMAL(9),
|
||||
CITY CHAR(15));
|
||||
INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale');
|
||||
INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna');
|
||||
INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna');
|
||||
INSERT INTO STAFF VALUES ('E4','Don',12,'Deale');
|
||||
INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron');
|
||||
INSERT INTO PROJ VALUES ('P1','MXSS','Design',10000,'Deale');
|
||||
INSERT INTO PROJ VALUES ('P2','CALM','Code',30000,'Vienna');
|
||||
INSERT INTO PROJ VALUES ('P3','SDP','Test',30000,'Tampa');
|
||||
INSERT INTO PROJ VALUES ('P4','SDP','Design',20000,'Deale');
|
||||
INSERT INTO PROJ VALUES ('P5','IRM','Test',10000,'Vienna');
|
||||
INSERT INTO PROJ VALUES ('P6','PAYR','Design',50000,'Deale');
|
||||
SELECT EMPNUM, GRADE*1000
|
||||
FROM HU.STAFF WHERE GRADE * 1000 >
|
||||
ANY (SELECT SUM(BUDGET) FROM HU.PROJ
|
||||
GROUP BY CITY, PTYPE
|
||||
HAVING HU.PROJ.CITY = HU.STAFF.CITY);
|
||||
EMPNUM GRADE*1000
|
||||
E3 13000
|
||||
DROP SCHEMA HU;
|
||||
USE test;
|
||||
create table t1(f1 int);
|
||||
select f1 from t1 having max(f1)=f1;
|
||||
f1
|
||||
select f1 from t1 group by f1 having max(f1)=f1;
|
||||
f1
|
||||
set session sql_mode='ONLY_FULL_GROUP_BY';
|
||||
select f1 from t1 having max(f1)=f1;
|
||||
ERROR 42000: Non-grouping field 'f1' is used in HAVING clause
|
||||
select f1 from t1 group by f1 having max(f1)=f1;
|
||||
f1
|
||||
set session sql_mode='';
|
||||
drop table t1;
|
@ -1,41 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a int not null auto_increment,b int, primary key (a)) engine=heap auto_increment=3;
|
||||
insert into t1 values (1,1),(NULL,3),(NULL,4);
|
||||
delete from t1 where a=4;
|
||||
insert into t1 values (NULL,5),(NULL,6);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
3 3
|
||||
5 5
|
||||
6 6
|
||||
delete from t1 where a=6;
|
||||
replace t1 values (3,1);
|
||||
ALTER TABLE t1 add c int;
|
||||
replace t1 values (3,3,3);
|
||||
insert into t1 values (NULL,7,7);
|
||||
update t1 set a=8,b=b+1,c=c+1 where a=7;
|
||||
insert into t1 values (NULL,9,9);
|
||||
select * from t1;
|
||||
a b c
|
||||
1 1 NULL
|
||||
3 3 3
|
||||
5 5 NULL
|
||||
8 8 8
|
||||
9 9 9
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||
sval char(20)
|
||||
) engine=heap;
|
||||
insert into t1 values (NULL, "hello");
|
||||
insert into t1 values (NULL, "hey");
|
||||
select * from t1;
|
||||
skey sval
|
||||
1 hello
|
||||
2 hey
|
||||
select _rowid,t1._rowid,skey,sval from t1;
|
||||
_rowid _rowid skey sval
|
||||
1 1 1 hello
|
||||
2 2 2 hey
|
||||
drop table t1;
|
@ -1,297 +0,0 @@
|
||||
drop table if exists t1;
|
||||
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a=1 or a=0;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 a A NULL NULL NULL BTREE
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
select * from t1 where a=4;
|
||||
a b
|
||||
4 4
|
||||
update t1 set b=5 where a=4;
|
||||
update t1 set b=b+1 where a>=3;
|
||||
replace t1 values (3,3);
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 6
|
||||
alter table t1 add c int not null, add key using BTREE (c,a);
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(-2,-2),(-1,-1),(0,0),(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a > -3;
|
||||
select * from t1;
|
||||
a b
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
drop table t1;
|
||||
create table t1 (a int not null) engine=heap;
|
||||
insert into t1 values (869751),(736494),(226312),(802616),(728912);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
alter table t1 add unique uniq_id using BTREE (a);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
802616
|
||||
869751
|
||||
select * from t1 where a = 736494;
|
||||
a
|
||||
736494
|
||||
select * from t1 where a=869751 or a=736494;
|
||||
a
|
||||
736494
|
||||
869751
|
||||
select * from t1 where a in (869751,736494,226312,802616);
|
||||
a
|
||||
226312
|
||||
736494
|
||||
802616
|
||||
869751
|
||||
alter table t1 engine=myisam;
|
||||
explain select * from t1 where a in (869751,736494,226312,802616);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
|
||||
drop table t1;
|
||||
create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
|
||||
engine=heap;
|
||||
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
|
||||
explain select * from t1 where x=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref x x 4 const 1
|
||||
select * from t1 where x=1;
|
||||
x y
|
||||
1 1
|
||||
1 3
|
||||
select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
x y x y
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
1 3 1 1
|
||||
2 4 2 2
|
||||
2 5 2 2
|
||||
2 6 2 2
|
||||
explain select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL x NULL NULL NULL 6
|
||||
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
|
||||
drop table t1;
|
||||
create table t1 (a int) engine=heap;
|
||||
insert into t1 values(1);
|
||||
select max(a) from t1;
|
||||
max(a)
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using BTREE (a,b), key using BTREE (b) ) ENGINE=HEAP;
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 1
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
1 6
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 1
|
||||
1 1
|
||||
1 2
|
||||
1 2
|
||||
1 3
|
||||
1 3
|
||||
1 4
|
||||
1 4
|
||||
1 5
|
||||
1 5
|
||||
1 6
|
||||
1 6
|
||||
explain select * from tx where a=x order by a,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x SIMPLE tx ref a a x const x Using where
|
||||
explain select * from tx where a=x order by b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x SIMPLE tx ref a a x const x Using where
|
||||
select * from t1 where b=1;
|
||||
a b
|
||||
1 1
|
||||
1 1
|
||||
explain select * from tx where b=x;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
x SIMPLE tx ref b b x const x
|
||||
drop table t1;
|
||||
create table t1 (id int unsigned not null, primary key using BTREE (id)) engine=HEAP;
|
||||
insert into t1 values(1);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
1
|
||||
insert into t1 values(2);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
2
|
||||
replace into t1 values(1);
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table if exists t1;
|
||||
CREATE table t1(f1 int not null,f2 char(20) not
|
||||
null,index(f2)) engine=heap;
|
||||
INSERT into t1 set f1=12,f2="bill";
|
||||
INSERT into t1 set f1=13,f2="bill";
|
||||
INSERT into t1 set f1=14,f2="bill";
|
||||
INSERT into t1 set f1=15,f2="bill";
|
||||
INSERT into t1 set f1=16,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
delete from t1 where f2="bill";
|
||||
select * from t1;
|
||||
f1 f2
|
||||
16 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
drop table t1;
|
||||
create table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap;
|
||||
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
|
||||
explain select * from t1 where btn like "i%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
|
||||
explain select * from t1 where btn like "h%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range btn btn 10 NULL # Using where
|
||||
explain select * from t1 where btn like "a%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
|
||||
explain select * from t1 where btn like "b%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
|
||||
select * from t1 where btn like "ff%";
|
||||
btn
|
||||
select * from t1 where btn like " %";
|
||||
btn
|
||||
select * from t1 where btn like "q%";
|
||||
btn
|
||||
alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn;
|
||||
update t1 set new_col=left(btn,1);
|
||||
explain select * from t1 where btn="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref btn btn 10 const 1 Using where
|
||||
explain select * from t1 where btn="a" and new_col="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref btn btn 11 const,const 1 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
b int default NULL,
|
||||
KEY a using BTREE (a),
|
||||
UNIQUE b using BTREE (b)
|
||||
) engine=heap;
|
||||
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
|
||||
SELECT * FROM t1 WHERE a=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE a IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
a b
|
||||
NULL 99
|
||||
SELECT * FROM t1 WHERE b=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE b IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref b b 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE b<=>NULL;
|
||||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
ERROR 23000: Duplicate entry '3' for key 'b'
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=heap;
|
||||
INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
|
||||
SELECT * FROM t1 WHERE a=1 and b IS NULL;
|
||||
a b c
|
||||
1 NULL NULL
|
||||
1 NULL 1
|
||||
SELECT * FROM t1 WHERE a=1 and c IS NULL;
|
||||
a b c
|
||||
1 NULL NULL
|
||||
1 1 NULL
|
||||
SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL;
|
||||
a b c
|
||||
1 NULL NULL
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, primary key using BTREE (a)) engine=heap;
|
||||
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
|
||||
DELETE from t1 where a < 100;
|
||||
SELECT * from t1;
|
||||
a
|
||||
DROP TABLE t1;
|
||||
create table t1(a int not null, key using btree(a)) engine=heap;
|
||||
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
|
||||
select a from t1 where a > 2 order by a;
|
||||
a
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
delete from t1 where a < 4;
|
||||
select a from t1 order by a;
|
||||
a
|
||||
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
|
||||
select a from t1 where a > 4 order by a;
|
||||
a
|
||||
delete from t1 where a > 4;
|
||||
select a from t1 order by a;
|
||||
a
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
select a from t1 where a > 3 order by a;
|
||||
a
|
||||
delete from t1 where a >= 2;
|
||||
select a from t1 order by a;
|
||||
a
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
End of 4.1 tests
|
||||
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
|
||||
INSERT INTO t1 VALUES(0);
|
||||
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
|
||||
INDEX_LENGTH
|
||||
21
|
||||
UPDATE t1 SET val=1;
|
||||
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
|
||||
INDEX_LENGTH
|
||||
21
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
|
||||
INSERT INTO t1 VALUES(NULL),(NULL);
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
@ -1,368 +0,0 @@
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a=1 or a=0;
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
select * from t1 where a=4;
|
||||
a b
|
||||
4 4
|
||||
update t1 set b=5 where a=4;
|
||||
update t1 set b=b+1 where a>=3;
|
||||
replace t1 values (3,3);
|
||||
select * from t1;
|
||||
a b
|
||||
2 2
|
||||
3 3
|
||||
4 6
|
||||
alter table t1 add c int not null, add key using HASH (c,a);
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where a > 0;
|
||||
select * from t1;
|
||||
a b
|
||||
drop table t1;
|
||||
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4);
|
||||
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
drop table t1;
|
||||
create table t1 (a int not null) engine=heap;
|
||||
insert into t1 values (869751),(736494),(226312),(802616),(728912);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
alter table t1 add unique uniq_id using HASH (a);
|
||||
select * from t1 where a > 736494;
|
||||
a
|
||||
869751
|
||||
802616
|
||||
select * from t1 where a = 736494;
|
||||
a
|
||||
736494
|
||||
select * from t1 where a=869751 or a=736494;
|
||||
a
|
||||
736494
|
||||
869751
|
||||
select * from t1 where a in (869751,736494,226312,802616);
|
||||
a
|
||||
226312
|
||||
736494
|
||||
802616
|
||||
869751
|
||||
alter table t1 engine=myisam;
|
||||
explain select * from t1 where a in (869751,736494,226312,802616);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
|
||||
drop table t1;
|
||||
create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y))
|
||||
engine=heap;
|
||||
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
|
||||
select * from t1 where x=1;
|
||||
x y
|
||||
1 3
|
||||
1 1
|
||||
select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
x y x y
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
1 3 1 1
|
||||
2 4 2 2
|
||||
2 5 2 2
|
||||
2 6 2 2
|
||||
explain select * from t1,t1 as t2 where t1.x=t2.y;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL x NULL NULL NULL 6
|
||||
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
|
||||
drop table t1;
|
||||
create table t1 (a int) engine=heap;
|
||||
insert into t1 values(1);
|
||||
select max(a) from t1;
|
||||
max(a)
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) ENGINE=HEAP;
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
|
||||
select * from t1 where a=1;
|
||||
a b
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
1 6
|
||||
1 5
|
||||
1 4
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
drop table t1;
|
||||
create table t1 (id int unsigned not null, primary key using HASH (id)) engine=HEAP;
|
||||
insert into t1 values(1);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
1
|
||||
insert into t1 values(2);
|
||||
select max(id) from t1;
|
||||
max(id)
|
||||
2
|
||||
replace into t1 values(1);
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table t1;
|
||||
create table t1 (n int) engine=heap;
|
||||
drop table if exists t1;
|
||||
CREATE table t1(f1 int not null,f2 char(20) not
|
||||
null,index(f2)) engine=heap;
|
||||
INSERT into t1 set f1=12,f2="bill";
|
||||
INSERT into t1 set f1=13,f2="bill";
|
||||
INSERT into t1 set f1=14,f2="bill";
|
||||
INSERT into t1 set f1=15,f2="bill";
|
||||
INSERT into t1 set f1=16,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
INSERT into t1 set f1=12,f2="ted";
|
||||
delete from t1 where f2="bill";
|
||||
select * from t1;
|
||||
f1 f2
|
||||
16 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
12 ted
|
||||
drop table t1;
|
||||
create table t1 (btn char(10) not null, key using HASH (btn)) engine=heap;
|
||||
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
|
||||
explain select * from t1 where btn like "q%";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
|
||||
select * from t1 where btn like "q%";
|
||||
btn
|
||||
alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
|
||||
update t1 set new_col=left(btn,1);
|
||||
explain select * from t1 where btn="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
|
||||
explain select * from t1 where btn="a" and new_col="a";
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref btn btn 11 const,const 2 Using where
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int default NULL,
|
||||
b int default NULL,
|
||||
KEY a using HASH (a),
|
||||
UNIQUE b using HASH (b)
|
||||
) engine=heap;
|
||||
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
|
||||
SELECT * FROM t1 WHERE a=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE a IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 5 const 2 Using where
|
||||
SELECT * FROM t1 WHERE a<=>NULL;
|
||||
a b
|
||||
NULL 99
|
||||
SELECT * FROM t1 WHERE b=NULL;
|
||||
a b
|
||||
explain SELECT * FROM t1 WHERE b IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref b b 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE b<=>NULL;
|
||||
a b
|
||||
99 NULL
|
||||
INSERT INTO t1 VALUES (1,3);
|
||||
ERROR 23000: Duplicate entry '3' for key 'b'
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int not null, primary key using HASH (a)) engine=heap;
|
||||
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
|
||||
DELETE from t1 where a < 100;
|
||||
SELECT * from t1;
|
||||
a
|
||||
DROP TABLE t1;
|
||||
create table t1
|
||||
(
|
||||
a char(8) not null,
|
||||
b char(20) not null,
|
||||
c int not null,
|
||||
key (a)
|
||||
) engine=heap;
|
||||
insert into t1 values ('aaaa', 'prefill-hash=5',0);
|
||||
insert into t1 values ('aaab', 'prefill-hash=0',0);
|
||||
insert into t1 values ('aaac', 'prefill-hash=7',0);
|
||||
insert into t1 values ('aaad', 'prefill-hash=2',0);
|
||||
insert into t1 values ('aaae', 'prefill-hash=1',0);
|
||||
insert into t1 values ('aaaf', 'prefill-hash=4',0);
|
||||
insert into t1 values ('aaag', 'prefill-hash=3',0);
|
||||
insert into t1 values ('aaah', 'prefill-hash=6',0);
|
||||
explain select * from t1 where a='aaaa';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaac';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaad';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
insert into t1 select * from t1;
|
||||
flush tables;
|
||||
explain select * from t1 where a='aaaa';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaac';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaad';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
flush tables;
|
||||
explain select * from t1 where a='aaaa';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaac';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaad';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
create table t2 as select * from t1;
|
||||
delete from t1;
|
||||
insert into t1 select * from t2;
|
||||
explain select * from t1 where a='aaaa';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaab';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaac';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
explain select * from t1 where a='aaad';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref a a 8 const 2 Using where
|
||||
drop table t1, t2;
|
||||
create table t1 (
|
||||
id int unsigned not null primary key auto_increment,
|
||||
name varchar(20) not null,
|
||||
index heap_idx(name),
|
||||
index btree_idx using btree(name)
|
||||
) engine=heap;
|
||||
create table t2 (
|
||||
id int unsigned not null primary key auto_increment,
|
||||
name varchar(20) not null,
|
||||
index btree_idx using btree(name),
|
||||
index heap_idx(name)
|
||||
) engine=heap;
|
||||
insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'),
|
||||
('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'),
|
||||
('Emily'), ('Mike');
|
||||
insert into t2 select * from t1;
|
||||
explain select * from t1 where name='matt';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t2 where name='matt';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t1 where name='Lilu';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t2 where name='Lilu';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t1 where name='Phil';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t2 where name='Phil';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t1 where name='Lilu';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where
|
||||
explain select * from t2 where name='Lilu';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
insert into t1 (name) select name from t2;
|
||||
flush tables;
|
||||
select count(*) from t1 where name='Matt';
|
||||
count(*)
|
||||
7
|
||||
explain select * from t1 ignore index (btree_idx) where name='matt';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx heap_idx 22 const 7 Using where
|
||||
show index from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH
|
||||
t1 1 heap_idx 1 name NULL 13 NULL NULL HASH
|
||||
t1 1 btree_idx 1 name A NULL NULL NULL BTREE
|
||||
show index from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH
|
||||
t1 1 heap_idx 1 name NULL 13 NULL NULL HASH
|
||||
t1 1 btree_idx 1 name A NULL NULL NULL BTREE
|
||||
create table t3
|
||||
(
|
||||
a varchar(20) not null,
|
||||
b varchar(20) not null,
|
||||
key (a,b)
|
||||
) engine=heap;
|
||||
insert into t3 select name, name from t1;
|
||||
show index from t3;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t3 1 a 1 a NULL NULL NULL NULL HASH
|
||||
t3 1 a 2 b NULL 13 NULL NULL HASH
|
||||
show index from t3;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
t3 1 a 1 a NULL NULL NULL NULL HASH
|
||||
t3 1 a 2 b NULL 13 NULL NULL HASH
|
||||
explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref heap_idx heap_idx 22 const 7 Using where
|
||||
1 SIMPLE t3 ref a a 44 func,const 7 Using where
|
||||
drop table t1, t2, t3;
|
||||
create temporary table t1 ( a int, index (a) ) engine=memory;
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
select a from t1 where a in (1,3);
|
||||
a
|
||||
1
|
||||
3
|
||||
explain select a from t1 where a in (1,3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 4 Using where
|
||||
drop table t1;
|
@ -1,268 +0,0 @@
|
||||
insert into mysql.help_category(help_category_id,name)values(10001,'impossible_category_1');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @category1_id:= 10001;
|
||||
@category1_id:= 10001
|
||||
10001
|
||||
insert into mysql.help_category(help_category_id,name)values(10002,'impossible_category_2');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @category2_id:= 10002;
|
||||
@category2_id:= 10002
|
||||
10002
|
||||
insert into mysql.help_category(help_category_id,name,parent_category_id)values(10003,'impossible_category_3',@category2_id);
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @category3_id:= 10003;
|
||||
@category3_id:= 10003
|
||||
10003
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10101,'impossible_function_1',@category1_id,'description of \n impossible_function1\n','example of \n impossible_function1');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic1_id:= 10101;
|
||||
@topic1_id:= 10101
|
||||
10101
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10102,'impossible_function_2',@category1_id,'description of \n impossible_function2\n','example of \n impossible_function2');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic2_id:= 10102;
|
||||
@topic2_id:= 10102
|
||||
10102
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10103,'impossible_function_3',@category2_id,'description of \n impossible_function3\n','example of \n impossible_function3');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic3_id:= 10103;
|
||||
@topic3_id:= 10103
|
||||
10103
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10104,'impossible_function_4',@category2_id,'description of \n impossible_function4\n','example of \n impossible_function4');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic4_id:= 10104;
|
||||
@topic4_id:= 10104
|
||||
10104
|
||||
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(10105,'impossible_function_7',@category3_id,'description of \n impossible_function5\n','example of \n impossible_function7');
|
||||
Warnings:
|
||||
Warning 1364 Field 'url' doesn't have a default value
|
||||
select @topic5_id:= 10105;
|
||||
@topic5_id:= 10105
|
||||
10105
|
||||
insert into mysql.help_keyword(help_keyword_id,name)values(10201,'impossible_function_1');
|
||||
select @keyword1_id:= 10201;
|
||||
@keyword1_id:= 10201
|
||||
10201
|
||||
insert into mysql.help_keyword(help_keyword_id,name)values(10202,'impossible_function_5');
|
||||
select @keyword2_id:= 10202;
|
||||
@keyword2_id:= 10202
|
||||
10202
|
||||
insert into mysql.help_keyword(help_keyword_id,name)values(10203,'impossible_function_6');
|
||||
select @keyword3_id:= 10203;
|
||||
@keyword3_id:= 10203
|
||||
10203
|
||||
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword1_id,@topic2_id);
|
||||
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword2_id,@topic1_id);
|
||||
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic3_id);
|
||||
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic4_id);
|
||||
help 'function_of_my_dream';
|
||||
name is_it_category
|
||||
help '%possible_f%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
help 'impossible_func%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
help 'impossible_category%';
|
||||
name is_it_category
|
||||
impossible_category_1 Y
|
||||
impossible_category_2 Y
|
||||
impossible_category_3 Y
|
||||
help 'impossible_%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
impossible_category_1 Y
|
||||
impossible_category_2 Y
|
||||
impossible_category_3 Y
|
||||
help '%function_1';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help '%function_2';
|
||||
name description example
|
||||
impossible_function_2 description of
|
||||
impossible_function2
|
||||
example of
|
||||
impossible_function2
|
||||
help '%function_3';
|
||||
name description example
|
||||
impossible_function_3 description of
|
||||
impossible_function3
|
||||
example of
|
||||
impossible_function3
|
||||
help '%function_4';
|
||||
name description example
|
||||
impossible_function_4 description of
|
||||
impossible_function4
|
||||
example of
|
||||
impossible_function4
|
||||
help '%function_5';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help '%function_6';
|
||||
name is_it_category
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
help '%function_7';
|
||||
name description example
|
||||
impossible_function_7 description of
|
||||
impossible_function5
|
||||
example of
|
||||
impossible_function7
|
||||
help '%category_2';
|
||||
source_category_name name is_it_category
|
||||
impossible_category_2 impossible_function_3 N
|
||||
impossible_category_2 impossible_function_4 N
|
||||
impossible_category_2 impossible_category_3 Y
|
||||
help 'impossible_function_1';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help 'impossible_category_1';
|
||||
source_category_name name is_it_category
|
||||
impossible_category_1 impossible_function_1 N
|
||||
impossible_category_1 impossible_function_2 N
|
||||
alter table mysql.help_relation engine=innodb;
|
||||
alter table mysql.help_keyword engine=innodb;
|
||||
alter table mysql.help_topic engine=innodb;
|
||||
alter table mysql.help_category engine=innodb;
|
||||
help 'function_of_my_dream';
|
||||
name is_it_category
|
||||
help '%possible_f%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
help 'impossible_func%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
help 'impossible_category%';
|
||||
name is_it_category
|
||||
impossible_category_1 Y
|
||||
impossible_category_2 Y
|
||||
impossible_category_3 Y
|
||||
help 'impossible_%';
|
||||
name is_it_category
|
||||
impossible_function_1 N
|
||||
impossible_function_2 N
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
impossible_function_7 N
|
||||
impossible_category_1 Y
|
||||
impossible_category_2 Y
|
||||
impossible_category_3 Y
|
||||
help '%function_1';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help '%function_2';
|
||||
name description example
|
||||
impossible_function_2 description of
|
||||
impossible_function2
|
||||
example of
|
||||
impossible_function2
|
||||
help '%function_3';
|
||||
name description example
|
||||
impossible_function_3 description of
|
||||
impossible_function3
|
||||
example of
|
||||
impossible_function3
|
||||
help '%function_4';
|
||||
name description example
|
||||
impossible_function_4 description of
|
||||
impossible_function4
|
||||
example of
|
||||
impossible_function4
|
||||
help '%function_5';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help '%function_6';
|
||||
name is_it_category
|
||||
impossible_function_3 N
|
||||
impossible_function_4 N
|
||||
help '%function_7';
|
||||
name description example
|
||||
impossible_function_7 description of
|
||||
impossible_function5
|
||||
example of
|
||||
impossible_function7
|
||||
help '%category_2';
|
||||
source_category_name name is_it_category
|
||||
impossible_category_2 impossible_function_3 N
|
||||
impossible_category_2 impossible_function_4 N
|
||||
impossible_category_2 impossible_category_3 Y
|
||||
help 'impossible_function_1';
|
||||
name description example
|
||||
impossible_function_1 description of
|
||||
impossible_function1
|
||||
example of
|
||||
impossible_function1
|
||||
help 'impossible_category_1';
|
||||
source_category_name name is_it_category
|
||||
impossible_category_1 impossible_function_1 N
|
||||
impossible_category_1 impossible_function_2 N
|
||||
alter table mysql.help_relation engine=myisam;
|
||||
alter table mysql.help_keyword engine=myisam;
|
||||
alter table mysql.help_topic engine=myisam;
|
||||
alter table mysql.help_category engine=myisam;
|
||||
delete from mysql.help_topic where help_topic_id=@topic1_id;
|
||||
delete from mysql.help_topic where help_topic_id=@topic2_id;
|
||||
delete from mysql.help_topic where help_topic_id=@topic3_id;
|
||||
delete from mysql.help_topic where help_topic_id=@topic4_id;
|
||||
delete from mysql.help_topic where help_topic_id=@topic5_id;
|
||||
delete from mysql.help_category where help_category_id=@category3_id;
|
||||
delete from mysql.help_category where help_category_id=@category2_id;
|
||||
delete from mysql.help_category where help_category_id=@category1_id;
|
||||
delete from mysql.help_keyword where help_keyword_id=@keyword1_id;
|
||||
delete from mysql.help_keyword where help_keyword_id=@keyword2_id;
|
||||
delete from mysql.help_keyword where help_keyword_id=@keyword3_id;
|
||||
delete from mysql.help_relation where help_keyword_id=@keyword1_id and help_topic_id=@topic2_id;
|
||||
delete from mysql.help_relation where help_keyword_id=@keyword2_id and help_topic_id=@topic1_id;
|
||||
delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic3_id;
|
||||
delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic4_id;
|
||||
End of 4.1 tests.
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (i INT);
|
||||
LOCK TABLES t1 WRITE;
|
||||
HELP no_such_topic;
|
||||
name is_it_category
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
@ -1,364 +0,0 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (a int not null);
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (a+2);
|
||||
insert into t1 values (a+3),(a+4);
|
||||
insert into t1 values (5),(a+6);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
drop table t1;
|
||||
create table t1 (id int not null auto_increment primary key, username varchar(32) not null, unique (username));
|
||||
insert into t1 values (0,"mysql");
|
||||
insert into t1 values (0,"mysql ab");
|
||||
insert into t1 values (0,"mysql a");
|
||||
insert into t1 values (0,"r1manic");
|
||||
insert into t1 values (0,"r1man");
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello", i int);
|
||||
insert into t1 values (default,default,default,default), (default,default,default,default), (4,0,"a",5),(default,default,default,default);
|
||||
select a,t>0,c,i from t1;
|
||||
a t>0 c i
|
||||
1 1 hello NULL
|
||||
2 1 hello NULL
|
||||
4 0 a 5
|
||||
5 1 hello NULL
|
||||
truncate table t1;
|
||||
insert into t1 set a=default,t=default,c=default;
|
||||
insert into t1 set a=default,t=default,c=default,i=default;
|
||||
insert into t1 set a=4,t=0,c="a",i=5;
|
||||
insert into t1 set a=5,t=0,c="a",i=null;
|
||||
insert into t1 set a=default,t=default,c=default,i=default;
|
||||
select a,t>0,c,i from t1;
|
||||
a t>0 c i
|
||||
1 1 hello NULL
|
||||
2 1 hello NULL
|
||||
4 0 a 5
|
||||
5 0 a NULL
|
||||
6 1 hello NULL
|
||||
drop table t1;
|
||||
create table t1 (sid char(20), id int(2) NOT NULL auto_increment, key(sid, id));
|
||||
insert into t1 values ('skr',NULL),('skr',NULL),('test',NULL);
|
||||
select * from t1;
|
||||
sid id
|
||||
skr 1
|
||||
skr 2
|
||||
test 3
|
||||
insert into t1 values ('rts',NULL),('rts',NULL),('test',NULL);
|
||||
select * from t1;
|
||||
sid id
|
||||
rts 4
|
||||
rts 5
|
||||
skr 1
|
||||
skr 2
|
||||
test 3
|
||||
test 6
|
||||
drop table t1;
|
||||
create table t1 (id int NOT NULL DEFAULT 8);
|
||||
insert into t1 values(NULL);
|
||||
ERROR 23000: Column 'id' cannot be null
|
||||
insert into t1 values (1), (NULL), (2);
|
||||
Warnings:
|
||||
Warning 1048 Column 'id' cannot be null
|
||||
select * from t1;
|
||||
id
|
||||
1
|
||||
0
|
||||
2
|
||||
drop table t1;
|
||||
create table t1 (email varchar(50));
|
||||
insert into t1 values ('sasha@mysql.com'),('monty@mysql.com'),('foo@hotmail.com'),('foo@aol.com'),('bar@aol.com');
|
||||
create table t2(id int not null auto_increment primary key, t2 varchar(50), unique(t2));
|
||||
insert into t2 (t2) select distinct substring(email, locate('@', email)+1) from t1;
|
||||
select * from t2;
|
||||
id t2
|
||||
1 mysql.com
|
||||
2 hotmail.com
|
||||
3 aol.com
|
||||
drop table t1,t2;
|
||||
drop database if exists mysqltest;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
create table t1 (c int);
|
||||
insert into mysqltest.t1 set mysqltest.t1.c = '1';
|
||||
drop database mysqltest;
|
||||
use test;
|
||||
create table t1(number int auto_increment primary key, original_value varchar(50), f_double double, f_float float, f_double_7_2 double(7,2), f_float_4_3 float (4,3), f_double_u double unsigned, f_float_u float unsigned, f_double_15_1_u double(15,1) unsigned, f_float_3_1_u float (3,1) unsigned);
|
||||
set @value= "aa";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'f_double' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_7_2' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_4_3' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_15_1_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 1
|
||||
original_value aa
|
||||
f_double 0
|
||||
f_float 0
|
||||
f_double_7_2 0.00
|
||||
f_float_4_3 0.000
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
set @value= "1aa";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'f_double' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_7_2' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_4_3' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_15_1_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 2
|
||||
original_value 1aa
|
||||
f_double 1
|
||||
f_float 1
|
||||
f_double_7_2 1.00
|
||||
f_float_4_3 1.000
|
||||
f_double_u 1
|
||||
f_float_u 1
|
||||
f_double_15_1_u 1.0
|
||||
f_float_3_1_u 1.0
|
||||
set @value= "aa1";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'f_double' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_7_2' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_4_3' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_double_15_1_u' at row 1
|
||||
Warning 1265 Data truncated for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 3
|
||||
original_value aa1
|
||||
f_double 0
|
||||
f_float 0
|
||||
f_double_7_2 0.00
|
||||
f_float_4_3 0.000
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
set @value= "1e+1111111111a";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_double' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 4
|
||||
original_value 1e+1111111111a
|
||||
f_double 1.7976931348623157e308
|
||||
f_float 3.40282e38
|
||||
f_double_7_2 99999.99
|
||||
f_float_4_3 9.999
|
||||
f_double_u 1.7976931348623157e308
|
||||
f_float_u 3.40282e38
|
||||
f_double_15_1_u 99999999999999.9
|
||||
f_float_3_1_u 99.9
|
||||
set @value= "-1e+1111111111a";
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_double' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 5
|
||||
original_value -1e+1111111111a
|
||||
f_double -1.7976931348623157e308
|
||||
f_float -3.40282e38
|
||||
f_double_7_2 -99999.99
|
||||
f_float_4_3 -9.999
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
set @value= 1e+1111111111;
|
||||
ERROR 22007: Illegal double '1e+1111111111' value found during parsing
|
||||
set @value= -1e+1111111111;
|
||||
ERROR 22007: Illegal double '1e+1111111111' value found during parsing
|
||||
set @value= 1e+111;
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 6
|
||||
original_value 1e111
|
||||
f_double 1e111
|
||||
f_float 3.40282e38
|
||||
f_double_7_2 99999.99
|
||||
f_float_4_3 9.999
|
||||
f_double_u 1e111
|
||||
f_float_u 3.40282e38
|
||||
f_double_15_1_u 99999999999999.9
|
||||
f_float_3_1_u 99.9
|
||||
set @value= -1e+111;
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_float' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_7_2' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_4_3' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 7
|
||||
original_value -1e111
|
||||
f_double -1e111
|
||||
f_float -3.40282e38
|
||||
f_double_7_2 -99999.99
|
||||
f_float_4_3 -9.999
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
set @value= 1;
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 8
|
||||
original_value 1
|
||||
f_double 1
|
||||
f_float 1
|
||||
f_double_7_2 1.00
|
||||
f_float_4_3 1.000
|
||||
f_double_u 1
|
||||
f_float_u 1
|
||||
f_double_15_1_u 1.0
|
||||
f_float_3_1_u 1.0
|
||||
set @value= -1;
|
||||
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
|
||||
Warnings:
|
||||
Warning 1264 Out of range value for column 'f_double_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
|
||||
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
|
||||
select * from t1 where number =last_insert_id();
|
||||
number 9
|
||||
original_value -1
|
||||
f_double -1
|
||||
f_float -1
|
||||
f_double_7_2 -1.00
|
||||
f_float_4_3 -1.000
|
||||
f_double_u 0
|
||||
f_float_u 0
|
||||
f_double_15_1_u 0.0
|
||||
f_float_3_1_u 0.0
|
||||
drop table t1;
|
||||
create table t1(id1 int not null auto_increment primary key, t char(12));
|
||||
create table t2(id2 int not null, t char(12));
|
||||
create table t3(id3 int not null, t char(12), index(id3));
|
||||
select count(*) from t2;
|
||||
count(*)
|
||||
500
|
||||
insert into t2 select t1.* from t1, t2 t, t3 where t1.id1 = t.id2 and t.id2 = t3.id3;
|
||||
select count(*) from t2;
|
||||
count(*)
|
||||
25500
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 (a,b) values (a,b);
|
||||
insert into t1 SET a=1, b=a+1;
|
||||
insert into t1 (a,b) select 1,2;
|
||||
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
|
||||
prepare stmt1 from ' replace into t1 (a,a) select 100, ''hundred'' ';
|
||||
execute stmt1;
|
||||
ERROR 42000: Column 'a' specified twice
|
||||
insert into t1 (a,b,b) values (1,1,1);
|
||||
ERROR 42000: Column 'b' specified twice
|
||||
insert into t1 (a,a) values (1,1,1);
|
||||
ERROR 21S01: Column count doesn't match value count at row 1
|
||||
insert into t1 (a,a) values (1,1);
|
||||
ERROR 42000: Column 'a' specified twice
|
||||
insert into t1 SET a=1,b=2,a=1;
|
||||
ERROR 42000: Column 'a' specified twice
|
||||
insert into t1 (b,b) select 1,2;
|
||||
ERROR 42000: Column 'b' specified twice
|
||||
INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
|
||||
ERROR 42000: Column 'b' specified twice
|
||||
drop table t1;
|
||||
create table t1 (id int primary key, data int);
|
||||
insert into t1 values (1, 1), (2, 2), (3, 3);
|
||||
select row_count();
|
||||
row_count()
|
||||
3
|
||||
insert ignore into t1 values (1, 1);
|
||||
select row_count();
|
||||
row_count()
|
||||
0
|
||||
replace into t1 values (1, 11);
|
||||
select row_count();
|
||||
row_count()
|
||||
2
|
||||
replace into t1 values (4, 4);
|
||||
select row_count();
|
||||
row_count()
|
||||
1
|
||||
insert into t1 values (2, 2) on duplicate key update data= data + 10;
|
||||
select row_count();
|
||||
row_count()
|
||||
2
|
||||
insert into t1 values (5, 5) on duplicate key update data= data + 10;
|
||||
select row_count();
|
||||
row_count()
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (id int primary key auto_increment, data int, unique(data));
|
||||
insert ignore into t1 values(NULL,100),(NULL,110),(NULL,120);
|
||||
insert ignore into t1 values(NULL,10),(NULL,20),(NULL,110),(NULL,120),(NULL,100),(NULL,90);
|
||||
insert ignore into t1 values(NULL,130),(NULL,140),(500,110),(550,120),(450,100),(NULL,150);
|
||||
select * from t1 order by id;
|
||||
id data
|
||||
1 100
|
||||
2 110
|
||||
3 120
|
||||
4 10
|
||||
5 20
|
||||
6 90
|
||||
7 130
|
||||
8 140
|
||||
551 150
|
@ -1,706 +0,0 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
|
||||
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
|
||||
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
|
||||
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
|
||||
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
||||
ERROR 23000: Duplicate entry '16' for key 'PRIMARY'
|
||||
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
||||
select * from t2;
|
||||
payoutID
|
||||
1
|
||||
4
|
||||
6
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
14
|
||||
16
|
||||
19
|
||||
20
|
||||
22
|
||||
drop table t1,t2;
|
||||
CREATE TABLE `t1` (
|
||||
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
||||
`icone` tinyint(4) unsigned NOT NULL default '0',
|
||||
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
||||
`contenu` text NOT NULL,
|
||||
`pseudo` varchar(50) NOT NULL default '',
|
||||
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`ip` bigint(11) NOT NULL default '0',
|
||||
`signature` tinyint(1) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`)
|
||||
,KEY `ip` (`ip`),
|
||||
KEY `date` (`date`),
|
||||
KEY `pseudo` (`pseudo`),
|
||||
KEY `numreponse` (`numreponse`)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE `t2` (
|
||||
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
||||
`icone` tinyint(4) unsigned NOT NULL default '0',
|
||||
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
||||
`contenu` text NOT NULL,
|
||||
`pseudo` varchar(50) NOT NULL default '',
|
||||
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`ip` bigint(11) NOT NULL default '0',
|
||||
`signature` tinyint(1) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`),
|
||||
KEY `ip` (`ip`),
|
||||
KEY `date` (`date`),
|
||||
KEY `pseudo` (`pseudo`),
|
||||
KEY `numreponse` (`numreponse`)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2
|
||||
(numeropost,icone,numreponse,contenu,pseudo,date,ip,signature) VALUES
|
||||
(9,1,56,'test','joce','2001-07-25 13:50:53'
|
||||
,3649052399,0);
|
||||
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
||||
SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM t2
|
||||
WHERE numeropost=9 ORDER BY numreponse ASC;
|
||||
show variables like '%bulk%';
|
||||
Variable_name Value
|
||||
bulk_insert_buffer_size 8388608
|
||||
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
||||
SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2
|
||||
WHERE numeropost=9 ORDER BY numreponse ASC;
|
||||
DROP TABLE t1,t2;
|
||||
create table t1 (a int not null);
|
||||
create table t2 (a int not null);
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (a+2);
|
||||
insert into t1 values (a+3);
|
||||
insert into t1 values (4),(a+5);
|
||||
insert into t1 select * from t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
insert into t1 select * from t1 as t2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
insert into t2 select * from t1 as t2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
insert into t1 select t2.a from t1,t2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
insert into t1 select * from t1,t1;
|
||||
ERROR 42000: Not unique table/alias: 't1'
|
||||
drop table t1,t2;
|
||||
create table t1 (a int not null primary key, b char(10));
|
||||
create table t2 (a int not null, b char(10));
|
||||
insert into t1 values (1,"t1:1"),(3,"t1:3");
|
||||
insert into t2 values (2,"t2:2"), (3,"t2:3");
|
||||
insert into t1 select * from t2;
|
||||
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
|
||||
select * from t1;
|
||||
a b
|
||||
1 t1:1
|
||||
3 t1:3
|
||||
replace into t1 select * from t2;
|
||||
select * from t1;
|
||||
a b
|
||||
1 t1:1
|
||||
2 t2:2
|
||||
3 t2:3
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
|
||||
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
|
||||
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
|
||||
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1(
|
||||
Month date NOT NULL,
|
||||
Type tinyint(3) unsigned NOT NULL auto_increment,
|
||||
Field int(10) unsigned NOT NULL,
|
||||
Count int(10) unsigned NOT NULL,
|
||||
UNIQUE KEY Month (Month,Type,Field)
|
||||
);
|
||||
insert into t1 Values
|
||||
(20030901, 1, 1, 100),
|
||||
(20030901, 1, 2, 100),
|
||||
(20030901, 2, 1, 100),
|
||||
(20030901, 2, 2, 100),
|
||||
(20030901, 3, 1, 100);
|
||||
select * from t1;
|
||||
Month Type Field Count
|
||||
2003-09-01 1 1 100
|
||||
2003-09-01 1 2 100
|
||||
2003-09-01 2 1 100
|
||||
2003-09-01 2 2 100
|
||||
2003-09-01 3 1 100
|
||||
Select null, Field, Count From t1 Where Month=20030901 and Type=2;
|
||||
NULL Field Count
|
||||
NULL 1 100
|
||||
NULL 2 100
|
||||
create table t2(No int not null, Field int not null, Count int not null);
|
||||
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
|
||||
Warnings:
|
||||
Warning 1048 Column 'No' cannot be null
|
||||
Warning 1048 Column 'No' cannot be null
|
||||
select * from t2;
|
||||
No Field Count
|
||||
0 1 100
|
||||
0 2 100
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (
|
||||
ID int(11) NOT NULL auto_increment,
|
||||
NO int(11) NOT NULL default '0',
|
||||
SEQ int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (ID),
|
||||
KEY t1$NO (SEQ,NO)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1);
|
||||
select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1);
|
||||
ID NO SEQ
|
||||
1 1 1
|
||||
drop table t1;
|
||||
create table t1 (f1 int);
|
||||
create table t2 (ff1 int unique, ff2 int default 1);
|
||||
insert into t1 values (1),(1),(2);
|
||||
insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1;
|
||||
select * from t2;
|
||||
ff1 ff2
|
||||
1 2
|
||||
2 1
|
||||
drop table t1, t2;
|
||||
create table t1 (a int unique);
|
||||
create table t2 (a int, b int);
|
||||
create table t3 (c int, d int);
|
||||
insert into t1 values (1),(2);
|
||||
insert into t2 values (1,2);
|
||||
insert into t3 values (1,6),(3,7);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
insert into t1 select a from t2 on duplicate key update a= t1.a + t2.b;
|
||||
select * from t1;
|
||||
a
|
||||
2
|
||||
3
|
||||
insert into t1 select a+1 from t2 on duplicate key update t1.a= t1.a + t2.b+1;
|
||||
select * from t1;
|
||||
a
|
||||
3
|
||||
5
|
||||
insert into t1 select t3.c from t3 on duplicate key update a= a + t3.d;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
5
|
||||
10
|
||||
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a + 10;
|
||||
insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
|
||||
ERROR 23000: Column 'a' in field list is ambiguous
|
||||
insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
|
||||
ERROR 42S22: Unknown column 't2.a' in 'field list'
|
||||
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b;
|
||||
ERROR 42S22: Unknown column 't2.b' in 'field list'
|
||||
drop table t1,t2,t3;
|
||||
create table t1(f1 varchar(5) key);
|
||||
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
|
||||
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
|
||||
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
|
||||
select * from t1;
|
||||
f1
|
||||
2000
|
||||
2001
|
||||
2002
|
||||
drop table t1;
|
||||
create table t1(x int, y int);
|
||||
create table t2(x int, z int);
|
||||
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(x);
|
||||
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
|
||||
ERROR 42S22: Unknown column 'z' in 'field list'
|
||||
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
|
||||
ERROR 42S22: Unknown column 't2.x' in 'field list'
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (a int PRIMARY KEY);
|
||||
INSERT INTO t1 values (1), (2);
|
||||
INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (x int, y int);
|
||||
CREATE TABLE t2 (z int, y int);
|
||||
CREATE TABLE t3 (a int, b int);
|
||||
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
CREATE DATABASE bug21774_1;
|
||||
CREATE DATABASE bug21774_2;
|
||||
CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
|
||||
CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
|
||||
CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
|
||||
INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
|
||||
use bug21774_1;
|
||||
INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
|
||||
DROP DATABASE bug21774_1;
|
||||
DROP DATABASE bug21774_2;
|
@ -1,221 +0,0 @@
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
|
||||
INSERT t1 VALUES (1,2,10), (3,4,20);
|
||||
INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 20
|
||||
5 6 30
|
||||
INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 20
|
||||
5 6 130
|
||||
INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 1020
|
||||
5 6 130
|
||||
INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10010
|
||||
3 4 1020
|
||||
5 6 130
|
||||
INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4;
|
||||
ERROR 23000: Duplicate entry '4' for key 'b'
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10010
|
||||
3 4 1020
|
||||
5 6 130
|
||||
TRUNCATE TABLE t1;
|
||||
INSERT t1 VALUES (1,2,10), (3,4,20);
|
||||
INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10
|
||||
5 6 30
|
||||
3 4 120
|
||||
8 9 60
|
||||
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 120
|
||||
5 0 30
|
||||
8 9 60
|
||||
INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a);
|
||||
SELECT *, VALUES(a) FROM t1 order by a;
|
||||
a b c VALUES(a)
|
||||
1 2 10 NULL
|
||||
2 1 11 NULL
|
||||
3 4 127 NULL
|
||||
5 0 30 NULL
|
||||
8 9 60 NULL
|
||||
explain extended SELECT *, VALUES(a) FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL ROWS 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,values(`test`.`t1`.`a`) AS `VALUES(a)` from `test`.`t1`
|
||||
explain extended select * from t1 where values(a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL ROWS 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where values(`test`.`t1`.`a`)
|
||||
DROP TABLE t1;
|
||||
create table t1(a int primary key, b int);
|
||||
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
insert into t1 values(4,14),(5,15),(6,16),(7,17),(8,18)
|
||||
on duplicate key update b=b+10;
|
||||
affected rows: 7
|
||||
info: Records: 5 Duplicates: 2 Warnings: 0
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 14
|
||||
5 15
|
||||
6 16
|
||||
7 17
|
||||
8 18
|
||||
replace into t1 values(5,25),(6,26),(7,27),(8,28),(9,29);
|
||||
affected rows: 9
|
||||
info: Records: 5 Duplicates: 4 Warnings: 0
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 14
|
||||
5 25
|
||||
6 26
|
||||
7 27
|
||||
8 28
|
||||
9 29
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
|
||||
INSERT t1 VALUES (1,2,10), (3,4,20);
|
||||
INSERT t1 SELECT 5,6,30 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 20
|
||||
5 6 30
|
||||
INSERT t1 SELECT 5,7,40 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 20
|
||||
5 6 130
|
||||
INSERT t1 SELECT 8,4,50 FROM DUAL ON DUPLICATE KEY UPDATE c=c+1000;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 1020
|
||||
5 6 130
|
||||
INSERT t1 SELECT 1,4,60 FROM DUAL ON DUPLICATE KEY UPDATE c=c+10000;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10010
|
||||
3 4 1020
|
||||
5 6 130
|
||||
INSERT t1 SELECT 1,9,70 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100000, b=4;
|
||||
ERROR 23000: Duplicate entry '4' for key 'b'
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10010
|
||||
3 4 1020
|
||||
5 6 130
|
||||
TRUNCATE TABLE t1;
|
||||
INSERT t1 VALUES (1,2,10), (3,4,20);
|
||||
CREATE TABLE t2 (a INT, b INT, c INT, d INT);
|
||||
INSERT t2 VALUES (5,6,30,1), (7,4,40,1), (8,9,60,1);
|
||||
INSERT t2 VALUES (2,1,11,2), (7,4,40,2);
|
||||
INSERT t1 SELECT a,b,c FROM t2 WHERE d=1 ON DUPLICATE KEY UPDATE c=t1.c+100;
|
||||
SELECT * FROM t1;
|
||||
a b c
|
||||
1 2 10
|
||||
5 6 30
|
||||
3 4 120
|
||||
8 9 60
|
||||
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
|
||||
SELECT * FROM t1 order by a;
|
||||
a b c
|
||||
1 2 10
|
||||
3 4 120
|
||||
5 0 30
|
||||
8 9 60
|
||||
INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a);
|
||||
ERROR 23000: Column 'c' in field list is ambiguous
|
||||
INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a);
|
||||
SELECT *, VALUES(a) FROM t1 order by a;
|
||||
a b c VALUES(a)
|
||||
1 2 10 NULL
|
||||
2 1 11 NULL
|
||||
3 4 127 NULL
|
||||
5 0 30 NULL
|
||||
8 9 60 NULL
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
create table t1 (a int not null unique) engine=myisam;
|
||||
insert into t1 values (1),(2);
|
||||
insert ignore into t1 select 1 on duplicate key update a=2;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
insert ignore into t1 select a from t1 as t2 on duplicate key update a=t1.a+1 ;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
3
|
||||
insert into t1 select 1 on duplicate key update a=2;
|
||||
select * from t1;
|
||||
a
|
||||
2
|
||||
3
|
||||
insert into t1 select a from t1 on duplicate key update a=a+1 ;
|
||||
ERROR 23000: Column 'a' in field list is ambiguous
|
||||
insert ignore into t1 select a from t1 on duplicate key update a=t1.a+1 ;
|
||||
ERROR 23000: Column 't1.a' in field list is ambiguous
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a BIGINT(20) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (a)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1
|
||||
(
|
||||
a BIGINT UNSIGNED,
|
||||
b BIGINT UNSIGNED,
|
||||
PRIMARY KEY (a)
|
||||
);
|
||||
INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
45 1
|
||||
INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
45 2
|
||||
INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
|
||||
IF(VALUES(b) > t1.b, VALUES(b), t1.b);
|
||||
SELECT * FROM t1;
|
||||
a b
|
||||
45 2
|
||||
DROP TABLE t1;
|
@ -1,825 +0,0 @@
|
||||
drop table if exists t1,t2,t3;
|
||||
SET @save_optimizer_switch=@@optimizer_switch;
|
||||
SET optimizer_switch='outer_join_with_cache=off';
|
||||
CREATE TABLE t1 (S1 INT);
|
||||
CREATE TABLE t2 (S1 INT);
|
||||
INSERT INTO t1 VALUES (1);
|
||||
INSERT INTO t2 VALUES (2);
|
||||
SELECT * FROM t1 JOIN t2;
|
||||
S1 S1
|
||||
1 2
|
||||
SELECT * FROM t1 INNER JOIN t2;
|
||||
S1 S1
|
||||
1 2
|
||||
SELECT * from t1 JOIN t2 USING (S1);
|
||||
S1
|
||||
SELECT * FROM t1 INNER JOIN t2 USING (S1);
|
||||
S1
|
||||
SELECT * from t1 CROSS JOIN t2;
|
||||
S1 S1
|
||||
1 2
|
||||
SELECT * from t1 LEFT JOIN t2 USING(S1);
|
||||
S1
|
||||
1
|
||||
SELECT * from t1 LEFT JOIN t2 ON(t2.S1=2);
|
||||
S1 S1
|
||||
1 2
|
||||
SELECT * from t1 RIGHT JOIN t2 USING(S1);
|
||||
S1
|
||||
2
|
||||
SELECT * from t1 RIGHT JOIN t2 ON(t1.S1=1);
|
||||
S1 S1
|
||||
1 2
|
||||
drop table t1,t2;
|
||||
create table t1 (id int primary key);
|
||||
create table t2 (id int);
|
||||
insert into t1 values (75);
|
||||
insert into t1 values (79);
|
||||
insert into t1 values (78);
|
||||
insert into t1 values (77);
|
||||
replace into t1 values (76);
|
||||
replace into t1 values (76);
|
||||
insert into t1 values (104);
|
||||
insert into t1 values (103);
|
||||
insert into t1 values (102);
|
||||
insert into t1 values (101);
|
||||
insert into t1 values (105);
|
||||
insert into t1 values (106);
|
||||
insert into t1 values (107);
|
||||
insert into t2 values (107),(75),(1000);
|
||||
select t1.id, t2.id from t1, t2 where t2.id = t1.id;
|
||||
id id
|
||||
107 107
|
||||
75 75
|
||||
select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t1.id;
|
||||
id count(t2.id)
|
||||
75 1
|
||||
107 1
|
||||
select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t2.id;
|
||||
id count(t2.id)
|
||||
75 1
|
||||
107 1
|
||||
select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null;
|
||||
id id
|
||||
NULL 75
|
||||
explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 const PRIMARY NULL NULL NULL 1 Impossible ON condition
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
explain select t1.id, t2.id from t1, t2 where t2.id = t1.id and t1.id <0 and t1.id > 0;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
id int(11) NOT NULL auto_increment,
|
||||
token varchar(100) DEFAULT '' NOT NULL,
|
||||
count int(11) DEFAULT '0' NOT NULL,
|
||||
qty int(11),
|
||||
phone char(1) DEFAULT '' NOT NULL,
|
||||
timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY token (token(15)),
|
||||
KEY timestamp (timestamp),
|
||||
UNIQUE token_2 (token(75),count,phone)
|
||||
);
|
||||
INSERT INTO t1 VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');
|
||||
INSERT INTO t1 VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21');
|
||||
INSERT INTO t1 VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04');
|
||||
INSERT INTO t1 VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53');
|
||||
INSERT INTO t1 VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53');
|
||||
INSERT INTO t1 VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24');
|
||||
INSERT INTO t1 VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12');
|
||||
INSERT INTO t1 VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12');
|
||||
INSERT INTO t1 VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24');
|
||||
INSERT INTO t1 VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36');
|
||||
INSERT INTO t1 VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05');
|
||||
CREATE TABLE t2 (
|
||||
id int(11) NOT NULL auto_increment,
|
||||
category int(11) DEFAULT '0' NOT NULL,
|
||||
county int(11) DEFAULT '0' NOT NULL,
|
||||
state int(11) DEFAULT '0' NOT NULL,
|
||||
phones int(11) DEFAULT '0' NOT NULL,
|
||||
nophones int(11) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY category (category,county,state)
|
||||
);
|
||||
INSERT INTO t2 VALUES (3,2,11,12,5400,7800);
|
||||
INSERT INTO t2 VALUES (4,2,25,12,6500,11200);
|
||||
INSERT INTO t2 VALUES (5,1,37,6,10000,12000);
|
||||
select a.id, b.category as catid, b.state as stateid, b.county as countyid from t1 a, t2 b ignore index (primary) where (a.token ='a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id);
|
||||
id catid stateid countyid
|
||||
27 2 12 11
|
||||
28 2 12 11
|
||||
29 2 12 25
|
||||
26 1 6 37
|
||||
select a.id, b.category as catid, b.state as stateid, b.county as
|
||||
countyid from t1 a, t2 b where (a.token =
|
||||
'a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id) order by a.id;
|
||||
id catid stateid countyid
|
||||
26 1 6 37
|
||||
27 2 12 11
|
||||
28 2 12 11
|
||||
29 2 12 25
|
||||
drop table t1, t2;
|
||||
create table t1 (a int primary key);
|
||||
insert into t1 values(1),(2);
|
||||
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
|
||||
a
|
||||
1
|
||||
2
|
||||
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
|
||||
ERROR HY000: Too many tables; MariaDB can only use XX tables in a join
|
||||
select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
|
||||
a
|
||||
1
|
||||
2
|
||||
select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
|
||||
ERROR HY000: Too many tables; MariaDB can only use XX tables in a join
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int(11) NOT NULL,
|
||||
b int(11) NOT NULL,
|
||||
PRIMARY KEY (a,b)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,3);
|
||||
CREATE TABLE t2 (
|
||||
a int(11) default NULL
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (2),(3);
|
||||
SELECT t1.a,t2.a,b FROM t1,t2 WHERE t1.a=t2.a AND (t1.a=1 OR t1.a=2) AND b>=1 AND b<=3;
|
||||
a a b
|
||||
2 2 3
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1 (d DATE NOT NULL);
|
||||
CREATE TABLE t2 (d DATE NOT NULL);
|
||||
INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00');
|
||||
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL;
|
||||
d
|
||||
2001-08-01
|
||||
0000-00-00
|
||||
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE d IS NULL;
|
||||
d
|
||||
0000-00-00
|
||||
SELECT * from t1 WHERE t1.d IS NULL;
|
||||
d
|
||||
0000-00-00
|
||||
SELECT * FROM t1 WHERE 1/0 IS NULL;
|
||||
d
|
||||
2001-08-01
|
||||
0000-00-00
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
Document_ID varchar(50) NOT NULL default '',
|
||||
Contractor_ID varchar(6) NOT NULL default '',
|
||||
Language_ID char(3) NOT NULL default '',
|
||||
Expiration_Date datetime default NULL,
|
||||
Publishing_Date datetime default NULL,
|
||||
Title text,
|
||||
Column_ID varchar(50) NOT NULL default '',
|
||||
PRIMARY KEY (Language_ID,Document_ID,Contractor_ID)
|
||||
);
|
||||
INSERT INTO t1 VALUES ('xep80','1','ger','2001-12-31 20:00:00','2001-11-12 10:58:00','Kartenbestellung - jetzt auch online','anle'),('','999998','',NULL,NULL,NULL,'');
|
||||
CREATE TABLE t2 (
|
||||
Contractor_ID char(6) NOT NULL default '',
|
||||
Language_ID char(3) NOT NULL default '',
|
||||
Document_ID char(50) NOT NULL default '',
|
||||
CanRead char(1) default NULL,
|
||||
Customer_ID int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (Contractor_ID,Language_ID,Document_ID,Customer_ID)
|
||||
);
|
||||
INSERT INTO t2 VALUES ('5','ger','xep80','1',999999),('1','ger','xep80','1',999999);
|
||||
CREATE TABLE t3 (
|
||||
Language_ID char(3) NOT NULL default '',
|
||||
Column_ID char(50) NOT NULL default '',
|
||||
Contractor_ID char(6) NOT NULL default '',
|
||||
CanRead char(1) default NULL,
|
||||
Active char(1) default NULL,
|
||||
PRIMARY KEY (Language_ID,Column_ID,Contractor_ID)
|
||||
);
|
||||
INSERT INTO t3 VALUES ('ger','home','1','1','1'),('ger','Test','1','0','0'),('ger','derclu','1','0','0'),('ger','clubne','1','0','0'),('ger','philos','1','0','0'),('ger','clubko','1','0','0'),('ger','clubim','1','1','1'),('ger','progra','1','0','0'),('ger','progvo','1','0','0'),('ger','progsp','1','0','0'),('ger','progau','1','0','0'),('ger','progku','1','0','0'),('ger','progss','1','0','0'),('ger','nachl','1','0','0'),('ger','mitgli','1','0','0'),('ger','mitsu','1','0','0'),('ger','mitbus','1','0','0'),('ger','ergmar','1','1','1'),('ger','home','4','1','1'),('ger','derclu','4','1','1'),('ger','clubne','4','0','0'),('ger','philos','4','1','1'),('ger','clubko','4','1','1'),('ger','clubim','4','1','1'),('ger','progra','4','1','1'),('ger','progvo','4','1','1'),('ger','progsp','4','1','1'),('ger','progau','4','0','0'),('ger','progku','4','1','1'),('ger','progss','4','1','1'),('ger','nachl','4','1','1'),('ger','mitgli','4','0','0'),('ger','mitsu','4','0','0'),('ger','mitbus','4','0','0'),('ger','ergmar','4','1','1'),('ger','progra2','1','0','0'),('ger','archiv','4','1','1'),('ger','anmeld','4','1','1'),('ger','thema','4','1','1'),('ger','edito','4','1','1'),('ger','madis','4','1','1'),('ger','enma','4','1','1'),('ger','madis','1','1','1'),('ger','enma','1','1','1'),('ger','vorsch','4','0','0'),('ger','veranst','4','0','0'),('ger','anle','4','1','1'),('ger','redak','4','1','1'),('ger','nele','4','1','1'),('ger','aukt','4','1','1'),('ger','callcenter','4','1','1'),('ger','anle','1','0','0');
|
||||
delete from t1 where Contractor_ID='999998';
|
||||
insert into t1 (Contractor_ID) Values ('999998');
|
||||
SELECT DISTINCT COUNT(t1.Title) FROM t1,
|
||||
t2, t3 WHERE
|
||||
t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND
|
||||
t1.Language_ID='ger' AND '2001-12-21 23:14:24' >=
|
||||
Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND
|
||||
t1.Document_ID = t2.Document_ID AND
|
||||
t1.Language_ID = t2.Language_ID AND
|
||||
t1.Contractor_ID = t2.Contractor_ID AND (
|
||||
t2.Customer_ID = '4' OR
|
||||
t2.Customer_ID = '999999' OR
|
||||
t2.Customer_ID = '1' )AND t2.CanRead
|
||||
= '1' AND t1.Column_ID=t3.Column_ID AND
|
||||
t1.Language_ID=t3.Language_ID AND (
|
||||
t3.Contractor_ID = '4' OR
|
||||
t3.Contractor_ID = '999999' OR
|
||||
t3.Contractor_ID = '1') AND
|
||||
t3.CanRead='1' AND t3.Active='1';
|
||||
COUNT(t1.Title)
|
||||
1
|
||||
SELECT DISTINCT COUNT(t1.Title) FROM t1,
|
||||
t2, t3 WHERE
|
||||
t1.Document_ID='xep80' AND t1.Contractor_ID='1' AND
|
||||
t1.Language_ID='ger' AND '2001-12-21 23:14:24' >=
|
||||
Publishing_Date AND '2001-12-21 23:14:24' <= Expiration_Date AND
|
||||
t1.Document_ID = t2.Document_ID AND
|
||||
t1.Language_ID = t2.Language_ID AND
|
||||
t1.Contractor_ID = t2.Contractor_ID AND (
|
||||
t2.Customer_ID = '4' OR
|
||||
t2.Customer_ID = '999999' OR
|
||||
t2.Customer_ID = '1' )AND t2.CanRead
|
||||
= '1' AND t1.Column_ID=t3.Column_ID AND
|
||||
t1.Language_ID=t3.Language_ID AND (
|
||||
t3.Contractor_ID = '4' OR
|
||||
t3.Contractor_ID = '999999' OR
|
||||
t3.Contractor_ID = '1') AND
|
||||
t3.CanRead='1' AND t3.Active='1';
|
||||
COUNT(t1.Title)
|
||||
1
|
||||
drop table t1,t2,t3;
|
||||
CREATE TABLE t1 (
|
||||
t1_id int(11) default NULL,
|
||||
t2_id int(11) default NULL,
|
||||
type enum('Cost','Percent') default NULL,
|
||||
cost_unit enum('Cost','Unit') default NULL,
|
||||
min_value double default NULL,
|
||||
max_value double default NULL,
|
||||
t3_id int(11) default NULL,
|
||||
item_id int(11) default NULL
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (12,5,'Percent','Cost',-1,0,-1,-1),(14,4,'Percent','Cost',-1,0,-1,-1),(18,5,'Percent','Cost',-1,0,-1,-1),(19,4,'Percent','Cost',-1,0,-1,-1),(20,5,'Percent','Cost',100,-1,22,291),(21,5,'Percent','Cost',100,-1,18,291),(22,1,'Percent','Cost',100,-1,6,291),(23,1,'Percent','Cost',100,-1,21,291),(24,1,'Percent','Cost',100,-1,9,291),(25,1,'Percent','Cost',100,-1,4,291),(26,1,'Percent','Cost',100,-1,20,291),(27,4,'Percent','Cost',100,-1,7,202),(28,1,'Percent','Cost',50,-1,-1,137),(29,2,'Percent','Cost',100,-1,4,354),(30,2,'Percent','Cost',100,-1,9,137),(93,2,'Cost','Cost',-1,10000000,-1,-1);
|
||||
CREATE TABLE t2 (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
name varchar(255) default NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,'s1'),(2,'s2'),(3,'s3'),(4,'s4'),(5,'s5');
|
||||
select t1.*, t2.* from t1, t2 where t2.id=t1.t2_id limit 2;
|
||||
t1_id t2_id type cost_unit min_value max_value t3_id item_id id name
|
||||
22 1 Percent Cost 100 -1 6 291 1 s1
|
||||
23 1 Percent Cost 100 -1 21 291 1 s1
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (
|
||||
siteid varchar(25) NOT NULL default '',
|
||||
emp_id varchar(30) NOT NULL default '',
|
||||
rate_code varchar(10) default NULL,
|
||||
UNIQUE KEY site_emp (siteid,emp_id),
|
||||
KEY siteid (siteid)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('rivercats','psmith','cust'), ('rivercats','KWalker','cust');
|
||||
CREATE TABLE t2 (
|
||||
siteid varchar(25) NOT NULL default '',
|
||||
rate_code varchar(10) NOT NULL default '',
|
||||
base_rate float NOT NULL default '0',
|
||||
PRIMARY KEY (siteid,rate_code),
|
||||
FULLTEXT KEY rate_code (rate_code)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('rivercats','cust',20);
|
||||
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND lr.siteid = 'rivercats';
|
||||
rate_code base_rate
|
||||
cust 20
|
||||
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE lr.siteid = 'rivercats' AND emp.emp_id = 'psmith';
|
||||
rate_code base_rate
|
||||
cust 20
|
||||
SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND siteid = 'rivercats';
|
||||
rate_code base_rate
|
||||
cust 20
|
||||
SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE siteid = 'rivercats' AND emp.emp_id = 'psmith';
|
||||
rate_code base_rate
|
||||
cust 20
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, Value1 VARCHAR(255));
|
||||
CREATE TABLE t2 (ID INTEGER NOT NULL PRIMARY KEY, Value2 VARCHAR(255));
|
||||
INSERT INTO t1 VALUES (1, 'A');
|
||||
INSERT INTO t2 VALUES (1, 'B');
|
||||
SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND (Value1 = 'A' AND Value2 <> 'B');
|
||||
ID Value1 Value2
|
||||
SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND Value1 = 'A' AND Value2 <> 'B';
|
||||
ID Value1 Value2
|
||||
SELECT * FROM t1 NATURAL JOIN t2 WHERE (Value1 = 'A' AND Value2 <> 'B') AND 1;
|
||||
ID Value1 Value2
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (a int);
|
||||
CREATE TABLE t2 (b int);
|
||||
CREATE TABLE t3 (c int);
|
||||
SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3;
|
||||
a b c
|
||||
DROP TABLE t1, t2, t3;
|
||||
create table t1 (i int);
|
||||
create table t2 (i int);
|
||||
create table t3 (i int);
|
||||
insert into t1 values(1),(2);
|
||||
insert into t2 values(2),(3);
|
||||
insert into t3 values (2),(4);
|
||||
select * from t1 natural left join t2;
|
||||
i
|
||||
1
|
||||
2
|
||||
select * from t1 left join t2 on (t1.i=t2.i);
|
||||
i i
|
||||
1 NULL
|
||||
2 2
|
||||
select * from t1 natural left join t2 natural left join t3;
|
||||
i
|
||||
1
|
||||
2
|
||||
select * from t1 left join t2 on (t1.i=t2.i) left join t3 on (t2.i=t3.i);
|
||||
i i i
|
||||
1 NULL NULL
|
||||
2 2 2
|
||||
select * from t3 natural right join t2;
|
||||
i
|
||||
2
|
||||
3
|
||||
select * from t3 right join t2 on (t3.i=t2.i);
|
||||
i i
|
||||
2 2
|
||||
NULL 3
|
||||
select * from t3 natural right join t2 natural right join t1;
|
||||
i
|
||||
1
|
||||
2
|
||||
select * from t3 right join t2 on (t3.i=t2.i) right join t1 on (t2.i=t1.i);
|
||||
i i i
|
||||
NULL NULL 1
|
||||
2 2 2
|
||||
select * from t1,t2 natural left join t3 order by t1.i,t2.i,t3.i;
|
||||
i i
|
||||
1 2
|
||||
1 3
|
||||
2 2
|
||||
2 3
|
||||
select * from t1,t2 left join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 2 2
|
||||
1 3 NULL
|
||||
2 2 2
|
||||
2 3 NULL
|
||||
select t1.i,t2.i,t3.i from t2 natural left join t3,t1 order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 2 2
|
||||
1 3 NULL
|
||||
2 2 2
|
||||
2 3 NULL
|
||||
select t1.i,t2.i,t3.i from t2 left join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 2 2
|
||||
1 3 NULL
|
||||
2 2 2
|
||||
2 3 NULL
|
||||
select * from t1,t2 natural right join t3 order by t1.i,t2.i,t3.i;
|
||||
i i
|
||||
1 4
|
||||
1 2
|
||||
2 4
|
||||
2 2
|
||||
select * from t1,t2 right join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 NULL 4
|
||||
1 2 2
|
||||
2 NULL 4
|
||||
2 2 2
|
||||
select t1.i,t2.i,t3.i from t2 natural right join t3,t1 order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 NULL 4
|
||||
1 2 2
|
||||
2 NULL 4
|
||||
2 2 2
|
||||
select t1.i,t2.i,t3.i from t2 right join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i;
|
||||
i i i
|
||||
1 NULL 4
|
||||
1 2 2
|
||||
2 NULL 4
|
||||
2 2 2
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (c int, b int);
|
||||
create table t2 (a int, b int);
|
||||
create table t3 (b int, c int);
|
||||
create table t4 (y int, c int);
|
||||
create table t5 (y int, z int);
|
||||
create table t6 (a int, c int);
|
||||
insert into t1 values (10,1);
|
||||
insert into t1 values (3 ,1);
|
||||
insert into t1 values (3 ,2);
|
||||
insert into t2 values (2, 1);
|
||||
insert into t3 values (1, 3);
|
||||
insert into t3 values (1,10);
|
||||
insert into t4 values (11,3);
|
||||
insert into t4 values (2, 3);
|
||||
insert into t5 values (11,4);
|
||||
insert into t6 values (2, 3);
|
||||
create algorithm=merge view v1a as
|
||||
select * from t1 natural join t2;
|
||||
create algorithm=merge view v1b(a,b,c) as
|
||||
select * from t1 natural join t2;
|
||||
create algorithm=merge view v1c as
|
||||
select b as a, c as b, a as c from t1 natural join t2;
|
||||
create algorithm=merge view v1d(b, a, c) as
|
||||
select a as c, c as b, b as a from t1 natural join t2;
|
||||
create algorithm=merge view v2a as
|
||||
select t1.c, t1.b, t2.a from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
|
||||
create algorithm=merge view v2b as
|
||||
select t1.c as b, t1.b as a, t2.a as c
|
||||
from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
|
||||
create algorithm=merge view v3a as
|
||||
select * from t1 natural join t2 natural join t3;
|
||||
create algorithm=merge view v3b as
|
||||
select * from t1 natural join (t2 natural join t3);
|
||||
create algorithm=merge view v4 as
|
||||
select * from v2a natural join v3a;
|
||||
select * from (t1 natural join t2) natural join (t3 natural join t4);
|
||||
b c a y
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (t1 natural join t2) natural left join (t3 natural join t4);
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (t3 natural join t4) natural right join (t1 natural join t2);
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (t1 natural left join t2) natural left join (t3 natural left join t4);
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
2 3 NULL NULL
|
||||
select * from (t4 natural right join t3) natural right join (t2 natural right join t1);
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
2 3 NULL NULL
|
||||
select * from t1 natural join t2 natural join t3 natural join t4;
|
||||
c b a y
|
||||
3 1 2 11
|
||||
3 1 2 2
|
||||
select * from ((t1 natural join t2) natural join t3) natural join t4;
|
||||
c b a y
|
||||
3 1 2 11
|
||||
3 1 2 2
|
||||
select * from t1 natural join (t2 natural join (t3 natural join t4));
|
||||
c b a y
|
||||
3 1 2 11
|
||||
3 1 2 2
|
||||
select * from t5 natural right join (t4 natural right join ((t2 natural right join t1) natural right join t3));
|
||||
y c b a z
|
||||
11 3 1 2 4
|
||||
2 3 1 2 NULL
|
||||
NULL 10 1 2 NULL
|
||||
select * from (t1 natural join t2), (t3 natural join t4);
|
||||
b c a c b y
|
||||
1 10 2 3 1 11
|
||||
1 10 2 3 1 2
|
||||
1 3 2 3 1 11
|
||||
1 3 2 3 1 2
|
||||
select * from t5 natural join ((t1 natural join t2), (t3 natural join t4));
|
||||
y z b c a c b
|
||||
11 4 1 10 2 3 1
|
||||
11 4 1 3 2 3 1
|
||||
select * from ((t1 natural join t2), (t3 natural join t4)) natural join t5;
|
||||
y b c a c b z
|
||||
11 1 10 2 3 1 4
|
||||
11 1 3 2 3 1 4
|
||||
select * from t5 natural join ((t1 natural join t2) cross join (t3 natural join t4));
|
||||
y z b c a c b
|
||||
11 4 1 10 2 3 1
|
||||
11 4 1 3 2 3 1
|
||||
select * from ((t1 natural join t2) cross join (t3 natural join t4)) natural join t5;
|
||||
y b c a c b z
|
||||
11 1 10 2 3 1 4
|
||||
11 1 3 2 3 1 4
|
||||
select * from (t1 join t2 using (b)) join (t3 join t4 using (c)) using (c);
|
||||
c b a b y
|
||||
3 1 2 1 11
|
||||
3 1 2 1 2
|
||||
select * from (t1 join t2 using (b)) natural join (t3 join t4 using (c));
|
||||
b c a y
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select a,b,c from (t1 natural join t2) natural join (t3 natural join t4)
|
||||
where b + 1 = y or b + 10 = y group by b,c,a having min(b) < max(y) order by a;
|
||||
a b c
|
||||
2 1 3
|
||||
select * from (t1 natural join t2) natural left join (t3 natural join t4)
|
||||
where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y;
|
||||
b c a y
|
||||
1 3 2 2
|
||||
1 3 2 11
|
||||
select * from (t3 natural join t4) natural right join (t1 natural join t2)
|
||||
where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y;
|
||||
b c a y
|
||||
1 3 2 2
|
||||
1 3 2 11
|
||||
select * from t1 natural join t2 where t1.c > t2.a;
|
||||
b c a
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from t1 natural join t2 where t1.b > t2.b;
|
||||
b c a
|
||||
select * from t1 natural left join (t4 natural join t5) where t5.z is not NULL;
|
||||
c b y z
|
||||
3 1 11 4
|
||||
3 2 11 4
|
||||
select * from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
|
||||
c b a b y c
|
||||
3 1 2 1 2 3
|
||||
3 2 2 1 2 3
|
||||
select * from (t2 join t4 on b + 1 = y) join t1 on t1.c = t4.c;
|
||||
a b y c c b
|
||||
2 1 2 3 3 1
|
||||
2 1 2 3 3 2
|
||||
select * from t1 natural join (t2 join t4 on b + 1 = y);
|
||||
c b a y
|
||||
3 1 2 2
|
||||
select * from (t1 cross join t2) join (t3 cross join t4) on (a < y and t2.b < t3.c);
|
||||
c b a b b c y c
|
||||
10 1 2 1 1 3 11 3
|
||||
10 1 2 1 1 10 11 3
|
||||
3 1 2 1 1 3 11 3
|
||||
3 1 2 1 1 10 11 3
|
||||
3 2 2 1 1 3 11 3
|
||||
3 2 2 1 1 10 11 3
|
||||
select * from (t1, t2) join (t3, t4) on (a < y and t2.b < t3.c);
|
||||
c b a b b c y c
|
||||
10 1 2 1 1 3 11 3
|
||||
10 1 2 1 1 10 11 3
|
||||
3 1 2 1 1 3 11 3
|
||||
3 1 2 1 1 10 11 3
|
||||
3 2 2 1 1 3 11 3
|
||||
3 2 2 1 1 10 11 3
|
||||
select * from (t1 natural join t2) join (t3 natural join t4) on a = y;
|
||||
b c a c b y
|
||||
1 10 2 3 1 2
|
||||
1 3 2 3 1 2
|
||||
select * from ((t3 join (t1 join t2 on c > a) on t3.b < t2.a) join t4 on y > t1.c) join t5 on z = t1.b + 3;
|
||||
b c c b a b y c y z
|
||||
1 3 10 1 2 1 11 3 11 4
|
||||
1 10 10 1 2 1 11 3 11 4
|
||||
1 3 3 1 2 1 11 3 11 4
|
||||
1 10 3 1 2 1 11 3 11 4
|
||||
select * from t1 natural join t2 where t1.b > 0;
|
||||
b c a
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from t1 natural join (t4 natural join t5) where t4.y > 7;
|
||||
c b y z
|
||||
3 1 11 4
|
||||
3 2 11 4
|
||||
select * from (t4 natural join t5) natural join t1 where t4.y > 7;
|
||||
c y z b
|
||||
3 11 4 1
|
||||
3 11 4 2
|
||||
select * from t1 natural left join (t4 natural join t5) where t4.y > 7;
|
||||
c b y z
|
||||
3 1 11 4
|
||||
3 2 11 4
|
||||
select * from (t4 natural join t5) natural right join t1 where t4.y > 7;
|
||||
c b y z
|
||||
3 1 11 4
|
||||
3 2 11 4
|
||||
select * from (t1 natural join t2) join (t3 natural join t4) on t1.b = t3.b;
|
||||
b c a c b y
|
||||
1 10 2 3 1 11
|
||||
1 10 2 3 1 2
|
||||
1 3 2 3 1 11
|
||||
1 3 2 3 1 2
|
||||
select t1.*, t2.* from t1 natural join t2;
|
||||
c b a b
|
||||
10 1 2 1
|
||||
3 1 2 1
|
||||
select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) natural join (t3 natural join t4);
|
||||
c b a b b c y c
|
||||
3 1 2 1 1 3 11 3
|
||||
3 1 2 1 1 3 2 3
|
||||
select * from (select * from t1 natural join t2) as t12
|
||||
natural join
|
||||
(select * from t3 natural join t4) as t34;
|
||||
b c a y
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (select * from t1 natural join t2) as t12
|
||||
natural left join
|
||||
(select * from t3 natural join t4) as t34;
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from (select * from t3 natural join t4) as t34
|
||||
natural right join
|
||||
(select * from t1 natural join t2) as t12;
|
||||
b c a y
|
||||
1 10 2 NULL
|
||||
1 3 2 11
|
||||
1 3 2 2
|
||||
select * from v1a;
|
||||
b c a
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from v1b;
|
||||
a b c
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from v1c;
|
||||
a b c
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from v1d;
|
||||
b a c
|
||||
2 10 1
|
||||
2 3 1
|
||||
select * from v2a;
|
||||
c b a
|
||||
3 1 2
|
||||
3 2 2
|
||||
select * from v2b;
|
||||
b a c
|
||||
3 1 2
|
||||
3 2 2
|
||||
select * from v3a;
|
||||
b c a
|
||||
1 10 2
|
||||
1 3 2
|
||||
select * from v3b;
|
||||
c b a
|
||||
10 1 2
|
||||
3 1 2
|
||||
select * from v4;
|
||||
c b a
|
||||
3 1 2
|
||||
select * from v1a natural join v2a;
|
||||
b c a
|
||||
1 3 2
|
||||
select v2a.* from v1a natural join v2a;
|
||||
c b a
|
||||
3 1 2
|
||||
select * from v1b join v2a on v1b.b = v2a.c;
|
||||
a b c c b a
|
||||
1 3 2 3 1 2
|
||||
1 3 2 3 2 2
|
||||
select * from v1c join v2a on v1c.b = v2a.c;
|
||||
a b c c b a
|
||||
1 3 2 3 1 2
|
||||
1 3 2 3 2 2
|
||||
select * from v1d join v2a on v1d.a = v2a.c;
|
||||
b a c c b a
|
||||
2 3 1 3 1 2
|
||||
2 3 1 3 2 2
|
||||
select * from v1a join (t3 natural join t4) on a = y;
|
||||
b c a c b y
|
||||
1 10 2 3 1 2
|
||||
1 3 2 3 1 2
|
||||
select * from t1 natural join (t3 cross join t4);
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from (t3 cross join t4) natural join t1;
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from t1 join (t2, t3) using (b);
|
||||
ERROR 23000: Column 'b' in from clause is ambiguous
|
||||
select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from t6 natural join ((t1 natural join t2), (t3 natural join t4));
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from (t1 join t2 on t1.b=t2.b) natural join (t3 natural join t4);
|
||||
ERROR 23000: Column 'b' in from clause is ambiguous
|
||||
select * from (t3 natural join t4) natural join (t1 join t2 on t1.b=t2.b);
|
||||
ERROR 23000: Column 'b' in from clause is ambiguous
|
||||
select * from (t3 join (t4 natural join t5) on (b < z))
|
||||
natural join
|
||||
(t1 natural join t2);
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select * from (t1 natural join t2) natural join (t3 join (t4 natural join t5) on (b < z));
|
||||
ERROR 23000: Column 'c' in from clause is ambiguous
|
||||
select t1.b from v1a;
|
||||
ERROR 42S22: Unknown column 't1.b' in 'field list'
|
||||
select * from v1a join v1b on t1.b = t2.b;
|
||||
ERROR 42S22: Unknown column 't1.b' in 'on clause'
|
||||
select * from information_schema.statistics join information_schema.columns
|
||||
using(table_name,column_name) where table_name='user';
|
||||
TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
|
||||
user Host def mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE def mysql 1 NO char 60 180 NULL NULL NULL utf8 utf8_bin char(60) PRI # select,insert,update,references
|
||||
user User def mysql 0 mysql PRIMARY 2 A 4 NULL NULL BTREE def mysql 2 NO char 16 48 NULL NULL NULL utf8 utf8_bin char(16) PRI # select,insert,update,references
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
drop table t4;
|
||||
drop table t5;
|
||||
drop table t6;
|
||||
drop view v1a;
|
||||
drop view v1b;
|
||||
drop view v1c;
|
||||
drop view v1d;
|
||||
drop view v2a;
|
||||
drop view v2b;
|
||||
drop view v3a;
|
||||
drop view v3b;
|
||||
drop view v4;
|
||||
create table t1 (a1 int, a2 int);
|
||||
create table t2 (a1 int, b int);
|
||||
create table t3 (c1 int, c2 int);
|
||||
create table t4 (c2 int);
|
||||
insert into t1 values (1,1);
|
||||
insert into t2 values (1,1);
|
||||
insert into t3 values (1,1);
|
||||
insert into t4 values (1);
|
||||
select * from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2);
|
||||
c2 a1 a2 b c1
|
||||
1 1 1 1 1
|
||||
select * from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2);
|
||||
c2 c1 a1 a2 b
|
||||
1 1 1 1 1
|
||||
select a2 from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2);
|
||||
a2
|
||||
1
|
||||
select a2 from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2);
|
||||
a2
|
||||
1
|
||||
select a2 from ((t1 join t2 using (a1)) join t3 on b=c1) join t4 using (c2);
|
||||
a2
|
||||
1
|
||||
select a2 from ((t1 natural join t2) join t3 on b=c1) natural join t4;
|
||||
a2
|
||||
1
|
||||
drop table t1,t2,t3,t4;
|
||||
create table t1 (c int, b int);
|
||||
create table t2 (a int, b int);
|
||||
create table t3 (b int, c int);
|
||||
create table t4 (y int, c int);
|
||||
create table t5 (y int, z int);
|
||||
insert into t1 values (3,2);
|
||||
insert into t2 values (1,2);
|
||||
insert into t3 values (2,3);
|
||||
insert into t4 values (1,3);
|
||||
insert into t5 values (1,4);
|
||||
prepare stmt1 from "select * from ((t3 natural join (t1 natural join t2))
|
||||
natural join t4) natural join t5";
|
||||
execute stmt1;
|
||||
y c b a z
|
||||
1 3 2 1 4
|
||||
select * from ((t3 natural join (t1 natural join t2)) natural join t4)
|
||||
natural join t5;
|
||||
y c b a z
|
||||
1 3 2 1 4
|
||||
drop table t1, t2, t3, t4, t5;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t2 (a int, b int, filler char(100), key(a), key(b));
|
||||
create table t3 (a int, b int, filler char(100), key(a), key(b));
|
||||
insert into t2
|
||||
select @a:= A.a + 10*(B.a + 10*C.a), @a, 'filler' from t1 A, t1 B, t1 C;
|
||||
insert into t3 select * from t2 where a < 800;
|
||||
explain select * from t2,t3 where t2.a < 200 and t2.b=t3.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range a,b a 5 NULL 1 Using where
|
||||
1 SIMPLE t3 ref b b 5 test.t2.b 1
|
||||
drop table t1, t2, t3;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t2 (a int, b int, primary key(a));
|
||||
insert into t2 select @v:=A.a+10*B.a, @v from t1 A, t1 B;
|
||||
explain select * from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
|
||||
show status like '%cost%';
|
||||
Variable_name Value
|
||||
Last_query_cost 4.262158
|
||||
select 'The cost of accessing t1 (dont care if it changes' '^';
|
||||
The cost of accessing t1 (dont care if it changes
|
||||
The cost of accessing t1 (dont care if it changes^
|
||||
select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z;
|
||||
Z
|
||||
vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv
|
||||
explain select * from t1, t2 A, t2 B where A.a = t1.a and B.a=A.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
1 SIMPLE A eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
|
||||
1 SIMPLE B eq_ref PRIMARY PRIMARY 4 test.A.b 1
|
||||
show status like '%cost%';
|
||||
Variable_name Value
|
||||
Last_query_cost 28.262158
|
||||
select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z;
|
||||
Z
|
||||
^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error
|
||||
drop table t1, t2;
|
||||
CREATE TABLE t1 (ID INTEGER, Name VARCHAR(50));
|
||||
CREATE TABLE t2 (Test_ID INTEGER);
|
||||
CREATE VIEW v1 (Test_ID, Description) AS SELECT ID, Name FROM t1;
|
||||
CREATE TABLE tv1 SELECT Description AS Name FROM v1 JOIN t2
|
||||
USING (Test_ID);
|
||||
DESCRIBE tv1;
|
||||
Field Type Null Key Default Extra
|
||||
Name varchar(50) YES NULL
|
||||
CREATE TABLE tv2 SELECT Description AS Name FROM v1 JOIN t2
|
||||
ON v1.Test_ID = t2.Test_ID;
|
||||
DESCRIBE tv2;
|
||||
Field Type Null Key Default Extra
|
||||
Name varchar(50) YES NULL
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,tv1,tv2;
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
End of 5.0 tests.
|
@ -1,103 +0,0 @@
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4;
|
||||
CREATE TABLE t1 (
|
||||
project_id int(11) NOT NULL auto_increment,
|
||||
project_row_lock int(11) NOT NULL default '0',
|
||||
project_name varchar(80) NOT NULL default '',
|
||||
client_ptr int(11) NOT NULL default '0',
|
||||
project_contact_ptr int(11) default NULL,
|
||||
client_contact_ptr int(11) default NULL,
|
||||
billing_contact_ptr int(11) default NULL,
|
||||
comments mediumtext,
|
||||
PRIMARY KEY (project_id),
|
||||
UNIQUE KEY project (client_ptr,project_name)
|
||||
) ENGINE=MyISAM PACK_KEYS=1;
|
||||
INSERT INTO t1 VALUES (1,0,'Rejected Time',1,NULL,NULL,NULL,NULL);
|
||||
INSERT INTO t1 VALUES (209,0,'MDGRAD Proposal/Investigation',97,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (208,0,'Font 9 Design',84,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (207,0,'Web Based Order Processing',95,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (205,0,'Mac Screen Saver',95,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (206,0,'Web Site',96,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (204,0,'Magnafire Glue',94,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (203,0,'Print Bid',93,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (202,0,'EPOC Port',92,NULL,NULL,NULL,'');
|
||||
INSERT INTO t1 VALUES (201,0,'TravelMate',88,NULL,NULL,NULL,'');
|
||||
CREATE TABLE t2 (
|
||||
period_id int(11) NOT NULL auto_increment,
|
||||
period_type enum('user_table','client_table','role_table','member_table','project_table') default NULL,
|
||||
period_key int(11) default NULL,
|
||||
start_date datetime default NULL,
|
||||
end_date datetime default NULL,
|
||||
work_load int(11) default NULL,
|
||||
PRIMARY KEY (period_id),
|
||||
KEY period_index (period_type,period_key),
|
||||
KEY date_index (start_date,end_date)
|
||||
) ENGINE=MyISAM PACK_KEYS=1;
|
||||
INSERT INTO t2 VALUES (1,'user_table',98,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (2,'user_table',99,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (3,'user_table',100,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (49,'project_table',148,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (50,'client_table',68,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (51,'project_table',149,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (52,'project_table',150,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (53,'client_table',69,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (54,'project_table',151,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (55,'client_table',70,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (155,'role_table',1,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (156,'role_table',2,'2000-01-01 00:00:00',NULL,NULL);
|
||||
INSERT INTO t2 VALUES (160,'member_table',1,'2000-01-01 00:00:00',NULL,1);
|
||||
INSERT INTO t2 VALUES (161,'member_table',2,'2000-01-01 00:00:00',NULL,1);
|
||||
INSERT INTO t2 VALUES (162,'member_table',3,'2000-01-01 00:00:00',NULL,1);
|
||||
CREATE TABLE t3 (
|
||||
budget_id int(11) NOT NULL auto_increment,
|
||||
project_ptr int(11) NOT NULL default '0',
|
||||
po_number varchar(20) NOT NULL default '',
|
||||
status enum('open','closed') default NULL,
|
||||
date_received datetime default NULL,
|
||||
amount_received float(10,2) default NULL,
|
||||
adjustment float(10,2) default NULL,
|
||||
PRIMARY KEY (budget_id),
|
||||
UNIQUE KEY po (project_ptr,po_number)
|
||||
) ENGINE=MyISAM PACK_KEYS=1;
|
||||
CREATE TABLE t4 (
|
||||
client_id int(11) NOT NULL auto_increment,
|
||||
client_row_lock int(11) NOT NULL default '0',
|
||||
client_name varchar(80) NOT NULL default '',
|
||||
contact_ptr int(11) default NULL,
|
||||
comments mediumtext,
|
||||
PRIMARY KEY (client_id),
|
||||
UNIQUE KEY client_name (client_name)
|
||||
) ENGINE=MyISAM PACK_KEYS=1;
|
||||
INSERT INTO t4 VALUES (1,0,'CPS',NULL,NULL);
|
||||
select distinct
|
||||
t1.project_id as project_id,
|
||||
t1.project_name as project_name,
|
||||
t1.client_ptr as client_ptr,
|
||||
t1.comments as comments,
|
||||
sum( t3.amount_received ) + sum( t3.adjustment ) as total_budget
|
||||
from
|
||||
t2 as client_period ,
|
||||
t2 as project_period,
|
||||
t3 left join t1 on (t3.project_ptr = t1.project_id and
|
||||
t3.date_received <= '2001-03-22 14:15:09')
|
||||
left join t4 on t4.client_id = t1.client_ptr
|
||||
where
|
||||
1
|
||||
and ( client_period.period_type = 'client_table'
|
||||
and client_period.period_key = t4.client_id
|
||||
and ( client_period.start_date <= '2001-03-22 14:15:09' or isnull( client_period.start_date ))
|
||||
and ( client_period.end_date > '2001-03-21 14:15:09' or isnull( client_period.end_date ))
|
||||
)
|
||||
and ( project_period.period_type = 'project_table'
|
||||
and project_period.period_key = t1.project_id
|
||||
and ( project_period.start_date <= '2001-03-22 14:15:09' or isnull( project_period.start_date ))
|
||||
and ( project_period.end_date > '2001-03-21 14:15:09' or isnull( project_period.end_date )) )
|
||||
group by
|
||||
client_id,
|
||||
project_id ,
|
||||
client_period.period_id ,
|
||||
project_period.period_id
|
||||
order by
|
||||
client_name asc,
|
||||
project_name asc;
|
||||
project_id project_name client_ptr comments total_budget
|
||||
DROP TABLE t1,t2,t3,t4;
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user