mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 19:06:14 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			127 lines
		
	
	
	
		
			6.7 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			127 lines
		
	
	
	
		
			6.7 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| create table t1 (a int, b blob) engine=MyISAM;
 | |
| create table t2 (c int, d blob) engine=MyISAM;
 | |
| create table t3 (e int, f blob) engine=MyISAM;
 | |
| insert into t1 values (5,5),(6,6);
 | |
| insert into t2 values (2,2),(3,3);
 | |
| insert into t3 values (1,1),(3,3);
 | |
| set SQL_MODE=ORACLE;
 | |
| (select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4);
 | |
| a	b
 | |
| 4	4
 | |
| 3	3
 | |
| explain extended
 | |
| (select a,b from t1) union (select c,d from t2) intersect (select e,f from t3) union (select 4,4);
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 | |
| 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 2	UNION	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 3	INTERSECT	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 4	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 | |
| NULL	UNIT RESULT	<unit1,2,3,4>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	
 | |
| Warnings:
 | |
| Note	1003	(/* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1") union (/* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2") intersect (/* select#3 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3") union (/* select#4 */ select 4 AS "4",4 AS "4")
 | |
| (select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4);
 | |
| e	f
 | |
| 5	5
 | |
| 3	3
 | |
| 6	6
 | |
| 4	4
 | |
| explain extended
 | |
| (select e,f from t3) intersect (select c,d from t2) union (select a,b from t1) union (select 4,4);
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 | |
| 1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 2	INTERSECT	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 3	UNION	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 4	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 | |
| NULL	UNIT RESULT	<unit1,2,3,4>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	
 | |
| Warnings:
 | |
| Note	1003	(/* select#1 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3") intersect (/* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2") union (/* select#3 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1") union (/* select#4 */ select 4 AS "4",4 AS "4")
 | |
| create table t12(c1 int);
 | |
| insert into t12 values(1);
 | |
| insert into t12 values(2);
 | |
| create table t13(c1 int);
 | |
| insert into t13 values(1);
 | |
| insert into t13 values(3);
 | |
| create table t234(c1 int);
 | |
| insert into t234 values(2);
 | |
| insert into t234 values(3);
 | |
| insert into t234 values(4);
 | |
| select * from t13 union select * from t234 intersect select * from t12;
 | |
| c1
 | |
| 1
 | |
| 2
 | |
| set SQL_MODE=default;
 | |
| drop table t1,t2,t3;
 | |
| drop table t12,t13, t234;
 | |
| create table t1 (a int, b blob) engine=MyISAM;
 | |
| create table t2 (c int, d blob) engine=MyISAM;
 | |
| create table t3 (e int, f blob) engine=MyISAM;
 | |
| insert into t1 values (5,5),(6,6);
 | |
| insert into t2 values (2,2),(3,3);
 | |
| insert into t3 values (1,1),(3,3);
 | |
| set SQL_MODE=ORACLE;
 | |
| select a,b from t1 union all select c,d from t2 intersect select e,f from t3 union all select 4,'4' from dual;
 | |
| a	b
 | |
| 4	4
 | |
| 3	3
 | |
| explain extended
 | |
| select a,b from t1 union all select c,d from t2 intersect select e,f from t3 union all select 4,'4' from dual;
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 | |
| 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 2	UNION	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 3	INTERSECT	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 4	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 | |
| NULL	UNIT RESULT	<unit1,2,3,4>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	
 | |
| Warnings:
 | |
| Note	1003	/* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" union all /* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2" intersect /* select#3 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3" union all /* select#4 */ select 4 AS "4",'4' AS "4"
 | |
| select a,b from t1 union all select c,d from t2 intersect all select e,f from t3 union all select 4,'4' from dual;
 | |
| a	b
 | |
| 3	3
 | |
| 4	4
 | |
| explain extended
 | |
| select a,b from t1 union all select c,d from t2 intersect all select e,f from t3 union all select 4,'4' from dual;
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 | |
| 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 2	UNION	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 3	INTERSECT	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 4	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 | |
| NULL	UNIT RESULT	<unit1,2,3,4>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	
 | |
| Warnings:
 | |
| Note	1003	/* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" union all /* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2" intersect all /* select#3 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3" union all /* select#4 */ select 4 AS "4",'4' AS "4"
 | |
| select e,f from t3 intersect select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual;
 | |
| e	f
 | |
| 5	5
 | |
| 3	3
 | |
| 6	6
 | |
| 4	4
 | |
| explain extended
 | |
| select e,f from t3 intersect select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual;
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 | |
| 1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 2	INTERSECT	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 3	UNION	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 4	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 | |
| NULL	UNIT RESULT	<unit1,2,3,4>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	
 | |
| Warnings:
 | |
| Note	1003	/* select#1 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3" intersect /* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2" union all /* select#3 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" union all /* select#4 */ select 4 AS "4",'4' AS "4"
 | |
| select e,f from t3 intersect all select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual;
 | |
| e	f
 | |
| 3	3
 | |
| 5	5
 | |
| 6	6
 | |
| 4	4
 | |
| explain extended
 | |
| select e,f from t3 intersect all select c,d from t2 union all select a,b from t1 union all select 4,'4' from dual;
 | |
| id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 | |
| 1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 2	INTERSECT	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 3	UNION	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
 | |
| 4	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 | |
| NULL	UNIT RESULT	<unit1,2,3,4>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	
 | |
| Warnings:
 | |
| Note	1003	/* select#1 */ select "test"."t3"."e" AS "e","test"."t3"."f" AS "f" from "test"."t3" intersect all /* select#2 */ select "test"."t2"."c" AS "c","test"."t2"."d" AS "d" from "test"."t2" union all /* select#3 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" union all /* select#4 */ select 4 AS "4",'4' AS "4"
 | |
| set SQL_MODE=default;
 | |
| drop table t1,t2,t3;
 | |
| set SQL_MODE=oracle;
 | |
| select * from t13 union select * from t234 intersect all select * from t12;
 | |
| ERROR 42S02: Table 'test.t13' doesn't exist
 | |
| set SQL_MODE=default;
 | 
