📄 ps_4heap.result
字号:
b=? and a = (select ? from t1 where outer_table.b = ? and outer_table.a=a ) ' ;execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;a ? b2 1 twoset @arg00=1 ;set @arg01=0 ;select a, @arg00 from ( select a - @arg00 as a from t1 where a=@arg00 ) as t2where a=@arg01;a @arg000 1prepare stmt1 from ' select a, ? from ( select a - ? as a from t1 where a=? ) as t2 where a=? ';execute stmt1 using @arg00, @arg00, @arg00, @arg01 ;a ?0 1drop table if exists t2 ;create table t2 as select * from t1;prepare stmt1 from ' select a in (select a from t2) from t1 ' ;execute stmt1 ;a in (select a from t2)1111drop table if exists t5, t6, t7 ;create table t5 (a int , b int) ;create table t6 like t5 ;create table t7 like t5 ;insert into t5 values (0, 100), (1, 2), (1, 3), (2, 2), (2, 7),(2, -1), (3, 10) ;insert into t6 values (0, 0), (1, 1), (2, 1), (3, 1), (4, 1) ;insert into t7 values (3, 3), (2, 2), (1, 1) ;prepare stmt1 from ' select a, (select count(distinct t5.b) as sum from t5, t6 where t5.a=t6.a and t6.b > 0 and t5.a <= t7.b group by t5.a order by sum limit 1) from t7 ' ;execute stmt1 ;a (select count(distinct t5.b) as sum from t5, t6 where t5.a=t6.a and t6.b > 0 and t5.a <= t7.b group by t5.a order by sum limit 1)3 12 21 2execute stmt1 ;a (select count(distinct t5.b) as sum from t5, t6 where t5.a=t6.a and t6.b > 0 and t5.a <= t7.b group by t5.a order by sum limit 1)3 12 21 2execute stmt1 ;a (select count(distinct t5.b) as sum from t5, t6 where t5.a=t6.a and t6.b > 0 and t5.a <= t7.b group by t5.a order by sum limit 1)3 12 21 2drop table t5, t6, t7 ;drop table if exists t2 ;create table t2 as select * from t9;set @stmt= ' SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 where (t9.c2 - 0e-3) = t2.c2 GROUP BY t9.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t9.c4) as exists_s, c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_sFROM t9,(select c25 x, c32 y from t2) tt WHERE x = c25 ' ;prepare stmt1 from @stmt ;execute stmt1 ;execute stmt1 ;set @stmt= concat('explain ',@stmt);prepare stmt1 from @stmt ;execute stmt1 ;execute stmt1 ;set @stmt= ' SELECT (SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2 GROUP BY t9.c15 LIMIT 1) as scalar_s, exists (select ? from t2 where t2.c3*?=t9.c4) as exists_s, c5*? in (select c6+? from t2) as in_s, (c7-?, c8-?) in (select c9+?, c10+? from t2) as in_row_sFROM t9,(select c25 x, c32 y from t2) tt WHERE x =c25 ' ;set @arg00= 0.0 ;set @arg01= 0e-3 ;set @arg02= 1.0e+0 ;set @arg03= 9.0000000000 ;set @arg04= 4 ;set @arg05= 0.3e+1 ;set @arg06= 4 ;set @arg07= 4 ;set @arg08= 4.0 ;set @arg09= 40e-1 ;prepare stmt1 from @stmt ;execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,@arg07, @arg08, @arg09 ;execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,@arg07, @arg08, @arg09 ;set @stmt= concat('explain ',@stmt);prepare stmt1 from @stmt ;execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,@arg07, @arg08, @arg09 ;execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06,@arg07, @arg08, @arg09 ;drop table t2 ;select 1 < (select a from t1) ;ERROR 21000: Subquery returns more than 1 rowprepare stmt1 from ' select 1 < (select a from t1) ' ;execute stmt1 ;ERROR 21000: Subquery returns more than 1 rowselect 1 as my_col ;my_col1test_sequence------ union tests ------prepare stmt1 from ' select a FROM t1 where a=1 union distinct select a FROM t1 where a=1 ';execute stmt1 ;a1execute stmt1 ;a1prepare stmt1 from ' select a FROM t1 where a=1 union all select a FROM t1 where a=1 ';execute stmt1 ;a11prepare stmt1 from ' SELECT 1, 2 union SELECT 1 ' ;ERROR 21000: The used SELECT statements have a different number of columnsprepare stmt1 from ' SELECT 1 union SELECT 1, 2 ' ;ERROR 21000: The used SELECT statements have a different number of columnsprepare stmt1 from ' SELECT * from t1 union SELECT 1 ' ;ERROR 21000: The used SELECT statements have a different number of columnsprepare stmt1 from ' SELECT 1 union SELECT * from t1 ' ;ERROR 21000: The used SELECT statements have a different number of columnsset @arg00=1 ;select @arg00 FROM t1 where a=1union distinctselect 1 FROM t1 where a=1;@arg001prepare stmt1 from ' select ? FROM t1 where a=1 union distinct select 1 FROM t1 where a=1 ' ;execute stmt1 using @arg00;?1set @arg00=1 ;select 1 FROM t1 where a=1union distinctselect @arg00 FROM t1 where a=1;11prepare stmt1 from ' select 1 FROM t1 where a=1 union distinct select ? FROM t1 where a=1 ' ;execute stmt1 using @arg00;11set @arg00='a' ;select @arg00 FROM t1 where a=1union distinctselect @arg00 FROM t1 where a=1;@arg00aprepare stmt1 from ' select ? FROM t1 where a=1 union distinct select ? FROM t1 where a=1 ';execute stmt1 using @arg00, @arg00;?aprepare stmt1 from ' select ? union distinct select ? ';execute stmt1 using @arg00, @arg00;?aset @arg00='a' ;set @arg01=1 ;set @arg02='a' ;set @arg03=2 ;select @arg00 FROM t1 where a=@arg01union distinctselect @arg02 FROM t1 where a=@arg03;@arg00aprepare stmt1 from ' select ? FROM t1 where a=? union distinct select ? FROM t1 where a=? ' ;execute stmt1 using @arg00, @arg01, @arg02, @arg03;?aset @arg00=1 ;prepare stmt1 from ' select sum(a) + 200, ? from t1union distinctselect sum(a) + 200, 1 from t1group by b ' ;execute stmt1 using @arg00;sum(a) + 200 ?210 1204 1201 1203 1202 1set @Oporto='Oporto' ;set @Lisboa='Lisboa' ;set @0=0 ;set @1=1 ;set @2=2 ;set @3=3 ;set @4=4 ;select @Oporto,@Lisboa,@0,@1,@2,@3,@4 ;@Oporto @Lisboa @0 @1 @2 @3 @4Oporto Lisboa 0 1 2 3 4select sum(a) + 200 as the_sum, @Oporto as the_town from t1group by bunion distinctselect sum(a) + 200, @Lisboa from t1group by b ;the_sum the_town204 Oporto201 Oporto203 Oporto202 Oporto204 Lisboa201 Lisboa203 Lisboa202 Lisboaprepare stmt1 from ' select sum(a) + 200 as the_sum, ? as the_town from t1 group by b union distinct select sum(a) + 200, ? from t1 group by b ' ;execute stmt1 using @Oporto, @Lisboa;the_sum the_town204 Oporto201 Oporto203 Oporto202 Oporto204 Lisboa201 Lisboa203 Lisboa202 Lisboaselect sum(a) + 200 as the_sum, @Oporto as the_town from t1where a > @1group by bunion distinctselect sum(a) + 200, @Lisboa from t1where a > @2group by b ;the_sum the_town204 Oporto203 Oporto202 Oporto204 Lisboa203 Lisboaprepare stmt1 from ' select sum(a) + 200 as the_sum, ? as the_town from t1 where a > ? group by b union distinct select sum(a) + 200, ? from t1 where a > ? group by b ' ;execute stmt1 using @Oporto, @1, @Lisboa, @2;the_sum the_town204 Oporto203 Oporto202 Oporto204 Lisboa203 Lisboaselect sum(a) + 200 as the_sum, @Oporto as the_town from t1where a > @1group by bhaving avg(a) > @2union distinctselect sum(a) + 200, @Lisboa from t1where a > @2group by b having avg(a) > @3;the_sum the_town204 Oporto203 Oporto204 Lisboaprepare stmt1 from ' select sum(a) + 200 as the_sum, ? as the_town from t1 where a > ? group by b having avg(a) > ? union distinct select sum(a) + 200, ? from t1 where a > ? group by b having avg(a) > ? ';execute stmt1 using @Oporto, @1, @2, @Lisboa, @2, @3;the_sum the_town204 Oporto203 Oporto204 Lisboatest_sequence------ explain select tests ------prepare stmt1 from ' explain select * from t9 ' ;execute stmt1;Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnrdef id 8 3 1 N 32929 0 63def select_type 253 19 6 N 1 31 8def table 253 64 2 Y 0 31 8def type 253 10 3 Y 0 31 8def possible_keys 253 4096 0 Y 0 31 8def key 253 64 0 Y 0 31 8def key_len 253 4096 0 Y 128 31 63def ref 253 1024 0 Y 0 31 8def rows 8 10 1 Y 32928 0 63def Extra 253 255 0 N 1 31 8id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t9 ALL NULL NULL NULL NULL 2 test_sequence------ delete tests ------delete from t1 ;insert into t1 values (1,'one');insert into t1 values (2,'two');insert into t1 values (3,'three');insert into t1 values (4,'four');commit ;delete from t9 ;insert into t9set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1,c10= 1, c11= 1, c12 = 1,c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11',c16= '11:11:11', c17= '2004',c18= 1, c19=true, c20= 'a', c21= '123456789a', c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext',c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext',c29= 'longblob', c30= 'longtext', c31='one', c32= 'monday';insert into t9set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9,c10= 9, c11= 9, c12 = 9,c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11',c16= '11:11:11', c17= '2004',c18= 1, c19=false, c20= 'a', c21= '123456789a', c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext',c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext',c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday';commit ;prepare stmt1 from 'delete from t1 where a=2' ;execute stmt1;select a,b from t1 where a=2;a bexecute stmt1;insert into t1 values(0,NULL);set @arg00=NULL;prepare stmt1 from 'delete from t1 where b=?' ;execute stmt1 using @arg00;select a,b from t1 where b is NULL ;a b0 NULLset @arg00='one';execute stmt1 using @arg00;select a,b from t1 where b=@arg00;a bprepare stmt1 from 'truncate table t1' ;test_sequence------ update tests ------delete from t1 ;insert into t1 values (1,'one');insert into t1 values (2,'two');insert into t1 values (3,'three');insert into t1 values (4,'four');commit ;delete from t9 ;insert into t9set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1,c10= 1, c11= 1, c12 = 1,c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11',c16= '11:11:11', c17= '2004',c18= 1, c19=true, c20= 'a', c21= '123456789a', c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext',c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext',c29= 'longblob', c30= 'longtext', c31='one', c32= 'monday';insert into t9set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9,c10= 9, c11= 9, c12 = 9,c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11',c16= '11:11:11', c17= '2004',c18= 1, c19=false, c20= 'a', c21= '123456789a', c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext',c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext',c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday';commit ;prepare stmt1 from 'update t1 set b=''a=two'' where a=2' ;execute stmt1;select a,b from t1 where a=2;a b2 a=twoexecute stmt1;select a,b from t1 where a=2;a b2 a=twoset @arg00=NULL;prepare stmt1 from 'update t1 set b=? where a=2' ;execute stmt1 using @arg00;select a,b from t1 where a=2;a b2 NULLset @arg00='two';execute stmt1 using @arg00;select a,b from t1 where a=2;a b2 twoset @arg00=2;prepare stmt1 from 'update t1 set b=NULL where a=?' ;execute stmt1 using @arg00;select a,b from t1 where a=@arg00;a b2 NULL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -