📄 ps_1general.result
字号:
drop table if exists t5, t6, t7, t8;drop database if exists mysqltest ;drop database if exists client_test_db;drop database if exists testtets;drop table if exists t1Aa,t2Aa,v1Aa,v2Aa;drop view if exists t1Aa,t2Aa,v1Aa,v2Aa;test_sequence------ basic tests ------drop table if exists t1, t9 ;create table t1(a int, b varchar(30),primary key(a)) engine = 'MYISAM' ;create table t9 (c1 tinyint, c2 smallint, c3 mediumint, c4 int,c5 integer, c6 bigint, c7 float, c8 double,c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4),c13 date, c14 datetime, c15 timestamp, c16 time,c17 year, c18 tinyint, c19 bool, c20 char,c21 char(10), c22 varchar(30), c23 tinyblob, c24 tinytext,c25 blob, c26 text, c27 mediumblob, c28 mediumtext,c29 longblob, c30 longtext, c31 enum('one', 'two', 'three'),c32 set('monday', 'tuesday', 'wednesday'),primary key(c1)) engine = 'MYISAM' ;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 stmt FROM ' select * from t1 where a = ? ' ;SET @var= 2 ;EXECUTE stmt USING @var ;a b2 twoselect * from t1 where a = @var ;a b2 twoDEALLOCATE PREPARE stmt ;prepare stmt1 from ' select 1 as my_col ' ;prepare stmt1 from ' select ? as my_col ' ;prepare ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1prepare stmt1 ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1prepare stmt1 from ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1prepare_garbage stmt1 from ' select 1 ' ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'prepare_garbage stmt1 from ' select 1 '' at line 1prepare stmt1 from_garbage ' select 1 ' ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from_garbage ' select 1 '' at line 1prepare stmt1 from ' select_garbage 1 ' ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select_garbage 1' at line 1prepare from ' select 1 ' ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from ' select 1 '' at line 1prepare stmt1 ' select 1 ' ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' select 1 '' at line 1prepare ? from ' select ? as my_col ' ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? from ' select ? as my_col '' at line 1set @arg00='select 1 as my_col';prepare stmt1 from @arg00;set @arg00='';prepare stmt1 from @arg00;ERROR 42000: Query was emptyset @arg00=NULL;prepare stmt1 from @arg01;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1prepare stmt1 from ' select * from t1 where a <= 2 ' ;prepare stmt1 from ' select * from t1 where x <= 2 ' ;ERROR 42S22: Unknown column 'x' in 'where clause'prepare stmt1 from ' insert into t1(a,x) values(?,?) ' ;ERROR 42S22: Unknown column 'x' in 'field list'prepare stmt1 from ' insert into t1(x,a) values(?,?) ' ;ERROR 42S22: Unknown column 'x' in 'field list'drop table if exists not_exist ;prepare stmt1 from ' select * from not_exist where a <= 2 ' ;ERROR 42S02: Table 'test.not_exist' doesn't existprepare stmt1 from ' insert into t1 values(? ' ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1prepare stmt1 from ' select a, b from t1 where a=? and where ' ;ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where' at line 2execute never_prepared ;ERROR HY000: Unknown prepared statement handler (never_prepared) given to EXECUTEprepare stmt1 from ' select * from t1 where a <= 2 ' ;prepare stmt1 from ' select * from not_exist where a <= 2 ' ;ERROR 42S02: Table 'test.not_exist' doesn't existexecute stmt1 ;ERROR HY000: Unknown prepared statement handler (stmt1) given to EXECUTEcreate table t5(a int primary key,b char(30),c int);insert into t5( a, b, c) values( 1, 'original table', 1);prepare stmt2 from ' select * from t5 ' ;execute stmt2 ;a b c1 original table 1drop table t5 ;execute stmt2 ;ERROR 42S02: Table 'test.t5' doesn't existcreate table t5(a int primary key,b char(30),c int);insert into t5( a, b, c) values( 9, 'recreated table', 9);execute stmt2 ;a b c9 recreated table 9drop table t5 ;create table t5(a int primary key,c int,b char(30));insert into t5( a, b, c) values( 9, 'recreated table', 9);execute stmt2 ;a b c9 recreated table 9drop table t5 ;create table t5(a int primary key,b char(30),c int,d timestamp default current_timestamp);insert into t5( a, b, c) values( 9, 'recreated table', 9);execute stmt2 ;a b c9 recreated table 9drop table t5 ;create table t5(a int primary key,d timestamp default current_timestamp,b char(30),c int);insert into t5( a, b, c) values( 9, 'recreated table', 9);execute stmt2 ;a b c9 recreated table 9drop table t5 ;create table t5(a timestamp default '2004-02-29 18:01:59',b char(30),c int);insert into t5( b, c) values( 'recreated table', 9);execute stmt2 ;a b c2004-02-29 18:01:59 recreated table 9drop table t5 ;create table t5(f1 int primary key,f2 char(30),f3 int);insert into t5( f1, f2, f3) values( 9, 'recreated table', 9);execute stmt2 ;ERROR 42S22: Unknown column 'test.t5.a' in 'field list'drop table t5 ;prepare stmt1 from ' select * from t1 where a <= 2 ' ;execute stmt1 ;a b1 one2 twoset @arg00=1 ;set @arg01='two' ;prepare stmt1 from ' select * from t1 where a <= ? ' ;execute stmt1 using @arg00;a b1 oneexecute stmt1 ;ERROR HY000: Incorrect arguments to EXECUTEexecute stmt1 using @arg00, @arg01;ERROR HY000: Incorrect arguments to EXECUTEexecute stmt1 using @not_set;a bdeallocate prepare never_prepared ;ERROR HY000: Unknown prepared statement handler (never_prepared) given to DEALLOCATE PREPAREprepare stmt1 from ' select * from t1 where a <= 2 ' ;prepare stmt1 from ' select * from not_exist where a <= 2 ' ;ERROR 42S02: Table 'test.not_exist' doesn't existdeallocate prepare stmt1;ERROR HY000: Unknown prepared statement handler (stmt1) given to DEALLOCATE PREPAREcreate table t5(a int primary key,b char(10));prepare stmt2 from ' select a,b from t5 where a <= 2 ' ;drop table t5 ;deallocate prepare stmt2;prepare stmt1 from ' select a from t1 where a <= 2 ' ;prepare stmt2 from ' select b from t1 where a <= 2 ' ;execute stmt2 ;bonetwoexecute stmt1 ;a12prepare stmt1 from ' select a from t1 where a <= 2 ' ;prepare stmt2 from ' select a from t1 where a <= 2 ' ;execute stmt2 ;a12execute stmt1 ;a12deallocate prepare stmt1 ;execute stmt2 ;a12test_sequence------ show and misc tests ------drop table if exists t2;create table t2 (a int primary key, b char(10));prepare stmt4 from ' show databases ';execute stmt4;Databaseinformation_schemamysqltestprepare stmt4 from ' show tables from test like ''t2%'' ';execute stmt4;Tables_in_test (t2%)t2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -