📄 ps_4heap.result
字号:
update t1 set b='two' where a=@arg00;set @arg00=2000;execute stmt1 using @arg00;select a,b from t1 where a=@arg00;a bset @arg00=2;set @arg01=22;prepare stmt1 from 'update t1 set a=? where a=?' ;execute stmt1 using @arg00, @arg00;select a,b from t1 where a=@arg00;a b2 twoexecute stmt1 using @arg01, @arg00;select a,b from t1 where a=@arg01;a b22 twoexecute stmt1 using @arg00, @arg01;select a,b from t1 where a=@arg00;a b2 twoset @arg00=NULL;set @arg01=2;execute stmt1 using @arg00, @arg01;Warnings:Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1select a,b from t1 order by a;a b0 two1 one3 three4 fourset @arg00=0;execute stmt1 using @arg01, @arg00;select a,b from t1 order by a;a b1 one2 two3 three4 fourset @arg00=23;set @arg01='two';set @arg02=2;set @arg03='two';set @arg04=2;drop table if exists t2;create table t2 as select a,b from t1 ;prepare stmt1 from 'update t1 set a=? where b=? and a in (select ? from t2 where b = ? or a = ?)';execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ;affected rows: 1info: Rows matched: 1 Changed: 1 Warnings: 0select a,b from t1 where a = @arg00 ;a b23 twoprepare stmt1 from 'update t1 set a=? where b=? and a not in (select ? from t2 where b = ? or a = ?)';execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ;affected rows: 1info: Rows matched: 1 Changed: 1 Warnings: 0select a,b from t1 order by a ;a b1 one2 two3 three4 fourdrop table t2 ;create table t2(a int, b varchar(30),primary key(a)) engine = 'HEAP' ;insert into t2(a,b) select a, b from t1 ;prepare stmt1 from 'update t1 set a=? where b=? and a in (select ? from t2 where b = ? or a = ?)';execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ;affected rows: 1info: Rows matched: 1 Changed: 1 Warnings: 0select a,b from t1 where a = @arg00 ;a b23 twoprepare stmt1 from 'update t1 set a=? where b=? and a not in (select ? from t2 where b = ? or a = ?)';execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ;affected rows: 1info: Rows matched: 1 Changed: 1 Warnings: 0select a,b from t1 order by a ;a b1 one2 two3 three4 fourdrop table t2 ;set @arg00=1;prepare stmt1 from 'update t1 set b=''bla''where a=2limit 1';execute stmt1 ;select a,b from t1 where b = 'bla' ;a b2 blaprepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?';execute stmt1 using @arg00;test_sequence------ insert 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 'insert into t1 values(5, ''five'' )';execute stmt1;select a,b from t1 where a = 5;a b5 fiveset @arg00='six' ;prepare stmt1 from 'insert into t1 values(6, ? )';execute stmt1 using @arg00;select a,b from t1 where b = @arg00;a b6 sixexecute stmt1 using @arg00;ERROR 23000: Duplicate entry '6' for key 1set @arg00=NULL ;prepare stmt1 from 'insert into t1 values(0, ? )';execute stmt1 using @arg00;select a,b from t1 where b is NULL;a b0 NULLset @arg00=8 ;set @arg01='eight' ;prepare stmt1 from 'insert into t1 values(?, ? )';execute stmt1 using @arg00, @arg01 ;select a,b from t1 where b = @arg01;a b8 eightset @NULL= null ;set @arg00= 'abc' ;execute stmt1 using @NULL, @NULL ;ERROR 23000: Column 'a' cannot be nullexecute stmt1 using @NULL, @NULL ;ERROR 23000: Column 'a' cannot be nullexecute stmt1 using @NULL, @arg00 ;ERROR 23000: Column 'a' cannot be nullexecute stmt1 using @NULL, @arg00 ;ERROR 23000: Column 'a' cannot be nullset @arg01= 10000 + 2 ;execute stmt1 using @arg01, @arg00 ;set @arg01= 10000 + 1 ;execute stmt1 using @arg01, @arg00 ;select * from t1 where a > 10000 order by a ;a b10001 abc10002 abcdelete from t1 where a > 10000 ;set @arg01= 10000 + 2 ;execute stmt1 using @arg01, @NULL ;set @arg01= 10000 + 1 ;execute stmt1 using @arg01, @NULL ;select * from t1 where a > 10000 order by a ;a b10001 NULL10002 NULLdelete from t1 where a > 10000 ;set @arg01= 10000 + 10 ;execute stmt1 using @arg01, @arg01 ;set @arg01= 10000 + 9 ;execute stmt1 using @arg01, @arg01 ;set @arg01= 10000 + 8 ;execute stmt1 using @arg01, @arg01 ;set @arg01= 10000 + 7 ;execute stmt1 using @arg01, @arg01 ;set @arg01= 10000 + 6 ;execute stmt1 using @arg01, @arg01 ;set @arg01= 10000 + 5 ;execute stmt1 using @arg01, @arg01 ;set @arg01= 10000 + 4 ;execute stmt1 using @arg01, @arg01 ;set @arg01= 10000 + 3 ;execute stmt1 using @arg01, @arg01 ;set @arg01= 10000 + 2 ;execute stmt1 using @arg01, @arg01 ;set @arg01= 10000 + 1 ;execute stmt1 using @arg01, @arg01 ;select * from t1 where a > 10000 order by a ;a b10001 1000110002 1000210003 1000310004 1000410005 1000510006 1000610007 1000710008 1000810009 1000910010 10010delete from t1 where a > 10000 ;set @arg00=81 ;set @arg01='8-1' ;set @arg02=82 ;set @arg03='8-2' ;prepare stmt1 from 'insert into t1 values(?,?),(?,?)';execute stmt1 using @arg00, @arg01, @arg02, @arg03 ;select a,b from t1 where a in (@arg00,@arg02) ;a b81 8-182 8-2set @arg00=9 ;set @arg01='nine' ;prepare stmt1 from 'insert into t1 set a=?, b=? ';execute stmt1 using @arg00, @arg01 ;select a,b from t1 where a = @arg00 ;a b9 nineset @arg00=6 ;set @arg01=1 ;prepare stmt1 from 'insert into t1 set a=?, b=''sechs'' on duplicate key update a=a + ?, b=concat(b,''modified'') ';execute stmt1 using @arg00, @arg01;select * from t1 order by a;a b0 NULL1 one2 two3 three4 four5 five7 sixmodified8 eight9 nine81 8-182 8-2set @arg00=81 ;set @arg01=1 ;execute stmt1 using @arg00, @arg01;ERROR 23000: Duplicate entry '82' for key 1drop table if exists t2 ;create table t2 (id int auto_increment primary key) ENGINE= 'HEAP' ;prepare stmt1 from ' select last_insert_id() ' ;insert into t2 values (NULL) ;execute stmt1 ;last_insert_id()1insert into t2 values (NULL) ;execute stmt1 ;last_insert_id()2drop table t2 ;set @1000=1000 ;set @x1000_2="x1000_2" ;set @x1000_3="x1000_3" ;set @x1000="x1000" ;set @1100=1100 ;set @x1100="x1100" ;set @100=100 ;set @updated="updated" ;insert into t1 values(1000,'x1000_1') ;insert into t1 values(@1000,@x1000_2),(@1000,@x1000_3)on duplicate key update a = a + @100, b = concat(b,@updated) ;select a,b from t1 where a >= 1000 order by a ;a b1000 x1000_31100 x1000_1updateddelete from t1 where a >= 1000 ;insert into t1 values(1000,'x1000_1') ;prepare stmt1 from ' insert into t1 values(?,?),(?,?) on duplicate key update a = a + ?, b = concat(b,?) ';execute stmt1 using @1000, @x1000_2, @1000, @x1000_3, @100, @updated ;select a,b from t1 where a >= 1000 order by a ;a b1000 x1000_31100 x1000_1updateddelete from t1 where a >= 1000 ;insert into t1 values(1000,'x1000_1') ;execute stmt1 using @1000, @x1000_2, @1100, @x1000_3, @100, @updated ;select a,b from t1 where a >= 1000 order by a ;a b1200 x1000_1updatedupdateddelete from t1 where a >= 1000 ;prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' ';execute stmt1;execute stmt1;execute stmt1;test_sequence------ multi table tests ------delete from t1 ;delete from t9 ;insert into t1(a,b) values (1, 'one'), (2, 'two'), (3, 'three') ;insert into t9 (c1,c21)values (1, 'one'), (2, 'two'), (3, 'three') ;prepare stmt_delete from " delete t1, t9 from t1, t9 where t1.a=t9.c1 and t1.b='updated' ";prepare stmt_update from " update t1, t9 set t1.b='updated', t9.c21='updated' where t1.a=t9.c1 and t1.a=? ";prepare stmt_select1 from " select a, b from t1 order by a" ;prepare stmt_select2 from " select c1, c21 from t9 order by c1" ;set @arg00= 1 ;execute stmt_update using @arg00 ;execute stmt_delete ;execute stmt_select1 ;a b2 two3 threeexecute stmt_select2 ;c1 c212 two3 threeset @arg00= @arg00 + 1 ;execute stmt_update using @arg00 ;execute stmt_delete ;execute stmt_select1 ;a b3 threeexecute stmt_select2 ;c1 c213 threeset @arg00= @arg00 + 1 ;execute stmt_update using @arg00 ;execute stmt_delete ;execute stmt_select1 ;a bexecute stmt_select2 ;c1 c21set @arg00= @arg00 + 1 ;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 ;insert into t1 values(0,NULL) ;set @duplicate='duplicate ' ;set @1000=1000 ;set @5=5 ;select a,b from t1 where a < 5 order by a ;a b0 NULL1 one2 two3 three4 fourinsert into t1 select a + @1000, concat(@duplicate,b) from t1where a < @5 ;affected rows: 5info: Records: 5 Duplicates: 0 Warnings: 0select a,b from t1 where a >= 1000 order by a ;a b1000 NULL1001 duplicate one1002 duplicate two1003 duplicate three1004 duplicate fourdelete from t1 where a >= 1000 ;prepare stmt1 from ' insert into t1 select a + ?, concat(?,b) from t1where a < ? ' ;execute stmt1 using @1000, @duplicate, @5;affected rows: 5info: Records: 5 Duplicates: 0 Warnings: 0select a,b from t1 where a >= 1000 order by a ;a b1000 NULL1001 duplicate one1002 duplicate two1003 duplicate three1004 duplicate fourdelete from t1 where a >= 1000 ;set @1=1 ;set @2=2 ;set @100=100 ;set @float=1.00;set @five='five' ;drop table if exists t2;create table t2 like t1 ;insert into t2 (b,a) select @duplicate, sum(first.a) from t1 first, t1 secondwhere first.a <> @5 and second.b = first.b
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -