mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +01:00
31a7a0d646
mysql-test/r/alter_table.result: Update test result mysql-test/r/analyse.result: Update test result mysql-test/r/archive.result: Update test result mysql-test/r/archive_bitfield.result: Update test result mysql-test/r/archive_gis.result: Update test result mysql-test/r/bdb.result: Update test result mysql-test/r/bdb_gis.result: Update test result mysql-test/r/bigint.result: Update test result mysql-test/r/binary.result: Update test result mysql-test/r/case.result: Update test result mysql-test/r/cast.result: Update test result mysql-test/r/constraints.result: Update test result mysql-test/r/create.result: Update test result mysql-test/r/ctype_collate.result: Update test result mysql-test/r/ctype_create.result: Update test result mysql-test/r/ctype_latin1_de.result: Update test result mysql-test/r/ctype_many.result: Update test result mysql-test/r/ctype_mb.result: Update test result mysql-test/r/ctype_recoding.result: Update test result mysql-test/r/ctype_sjis.result: Update test result mysql-test/r/ctype_tis620.result: Update test result mysql-test/r/ctype_ucs.result: Update test result mysql-test/r/ctype_ujis.result: Update test result mysql-test/r/ctype_utf8.result: Update test result mysql-test/r/default.result: Update test result mysql-test/r/events.result: Update test result mysql-test/r/federated.result: Update test result mysql-test/r/fulltext.result: Update test result mysql-test/r/func_gconcat.result: Update test result mysql-test/r/func_group.result: Update test result mysql-test/r/func_math.result: Update test result mysql-test/r/func_misc.result: Update test result mysql-test/r/func_str.result: Update test result mysql-test/r/func_system.result: Update test result mysql-test/r/gis-rtree.result: Update test result mysql-test/r/heap.result: Update test result mysql-test/r/index_merge_innodb.result: Update test result mysql-test/r/information_schema.result: Update test result mysql-test/r/innodb.result: Update test result mysql-test/r/innodb_gis.result: Update test result mysql-test/r/key.result: Update test result mysql-test/r/merge.result: Update test result mysql-test/r/myisam.result: Update test result mysql-test/r/mysqldump-max.result: Update test result mysql-test/r/mysqldump.result: Update test result mysql-test/r/ndb_bitfield.result: Update test result mysql-test/r/ndb_gis.result: Update test result mysql-test/r/ndb_partition_key.result: Update test result mysql-test/r/null.result: Update test result mysql-test/r/partition.result: Update test result mysql-test/r/partition_02myisam.result: Update test result mysql-test/r/partition_mgm_err.result: Update test result mysql-test/r/partition_range.result: Update test result mysql-test/r/ps_2myisam.result: Update test result mysql-test/r/ps_3innodb.result: Update test result mysql-test/r/ps_4heap.result: Update test result mysql-test/r/ps_5merge.result: Update test result mysql-test/r/ps_6bdb.result: Update test result mysql-test/r/rpl_mixed_ddl_dml.result: Update test result mysql-test/r/rpl_multi_engine.result: Update test result mysql-test/r/rpl_ndb_UUID.result: Update test result mysql-test/r/show_check.result: Update test result mysql-test/r/sp-vars.result: Update test result mysql-test/r/sp.result: Update test result mysql-test/r/sql_mode.result: Update test result mysql-test/r/strict.result: Update test result mysql-test/r/subselect.result: Update test result mysql-test/r/symlink.result: Update test result mysql-test/r/synchronization.result: Update test result mysql-test/r/system_mysql_db.result: Update test result mysql-test/r/temp_table.result: Update test result mysql-test/r/trigger.result: Update test result mysql-test/r/type_binary.result: Update test result mysql-test/r/type_bit.result: Update test result mysql-test/r/type_bit_innodb.result: Update test result mysql-test/r/type_blob.result: Update test result mysql-test/r/type_decimal.result: Update test result mysql-test/r/type_enum.result: Update test result mysql-test/r/type_float.result: Update test result mysql-test/r/type_nchar.result: Update test result mysql-test/r/type_newdecimal.result: Update test result mysql-test/r/type_set.result: Update test result mysql-test/r/type_timestamp.result: Update test result mysql-test/r/type_varchar.result: Update test result mysql-test/r/union.result: Update test result mysql-test/r/user_var.result: Update test result mysql-test/r/variables.result: Update test result sql/sql_show.cc: Make ouput from SHOW CREATE TABLE use uppercase for "CHARACTER SET", "COLLATE", "DEFAULT", "ON UPDATE" and "AUTO_INCREMENT"
143 lines
7.7 KiB
Text
143 lines
7.7 KiB
Text
drop table if exists t1,t2;
|
|
create table t1 (i int, j int, empty_string char(10), bool char(1), d date);
|
|
insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05");
|
|
select count(*) from t1 procedure analyse();
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
count(*) 4 4 1 1 0 0 4.0000 0.0000 ENUM('4') NOT NULL
|
|
select * from t1 procedure analyse();
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
|
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
|
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
|
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
|
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
|
select * from t1 procedure analyse(2);
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
|
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
|
|
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
|
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
|
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
|
create table t2 select * from t1 procedure analyse();
|
|
select * from t2;
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
|
|
test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
|
|
test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
|
|
test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
|
|
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
|
|
drop table t1,t2;
|
|
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
|
|
2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
|
create table t1 (a int not null);
|
|
create table t2 select * from t1 where 0=1 procedure analyse();
|
|
show create table t2;
|
|
Table Create Table
|
|
t2 CREATE TABLE `t2` (
|
|
`Field_name` varbinary(255) NOT NULL DEFAULT '',
|
|
`Min_value` varbinary(255) DEFAULT NULL,
|
|
`Max_value` varbinary(255) DEFAULT NULL,
|
|
`Min_length` bigint(11) NOT NULL DEFAULT '0',
|
|
`Max_length` bigint(11) NOT NULL DEFAULT '0',
|
|
`Empties_or_zeros` bigint(11) NOT NULL DEFAULT '0',
|
|
`Nulls` bigint(11) NOT NULL DEFAULT '0',
|
|
`Avg_value_or_avg_length` varbinary(255) NOT NULL DEFAULT '',
|
|
`Std` varbinary(255) DEFAULT NULL,
|
|
`Optimal_fieldtype` varbinary(64) NOT NULL DEFAULT ''
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
select * from t1 where 0=1 procedure analyse();
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
insert into t1 values(1);
|
|
drop table t2;
|
|
create table t2 select * from t1 where 0=1 procedure analyse();
|
|
show create table t2;
|
|
Table Create Table
|
|
t2 CREATE TABLE `t2` (
|
|
`Field_name` varbinary(255) NOT NULL DEFAULT '',
|
|
`Min_value` varbinary(255) DEFAULT NULL,
|
|
`Max_value` varbinary(255) DEFAULT NULL,
|
|
`Min_length` bigint(11) NOT NULL DEFAULT '0',
|
|
`Max_length` bigint(11) NOT NULL DEFAULT '0',
|
|
`Empties_or_zeros` bigint(11) NOT NULL DEFAULT '0',
|
|
`Nulls` bigint(11) NOT NULL DEFAULT '0',
|
|
`Avg_value_or_avg_length` varbinary(255) NOT NULL DEFAULT '',
|
|
`Std` varbinary(255) DEFAULT NULL,
|
|
`Optimal_fieldtype` varbinary(64) NOT NULL DEFAULT ''
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
select * from t2;
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
insert into t2 select * from t1 procedure analyse();
|
|
select * from t2;
|
|
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 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL
|
|
insert into t1 values(2);
|
|
drop table t2;
|
|
create table t2 select * from t1 where 0=1 procedure analyse();
|
|
show create table t2;
|
|
Table Create Table
|
|
t2 CREATE TABLE `t2` (
|
|
`Field_name` varbinary(255) NOT NULL DEFAULT '',
|
|
`Min_value` varbinary(255) DEFAULT NULL,
|
|
`Max_value` varbinary(255) DEFAULT NULL,
|
|
`Min_length` bigint(11) NOT NULL DEFAULT '0',
|
|
`Max_length` bigint(11) NOT NULL DEFAULT '0',
|
|
`Empties_or_zeros` bigint(11) NOT NULL DEFAULT '0',
|
|
`Nulls` bigint(11) NOT NULL DEFAULT '0',
|
|
`Avg_value_or_avg_length` varbinary(255) NOT NULL DEFAULT '',
|
|
`Std` varbinary(255) DEFAULT NULL,
|
|
`Optimal_fieldtype` varbinary(64) NOT NULL DEFAULT ''
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
select * from t2;
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
insert into t2 select * from t1 procedure analyse();
|
|
select * from t2;
|
|
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 1 2 1 1 0 0 1.5000 0.5000 ENUM('1','2') NOT NULL
|
|
drop table t1,t2;
|
|
create table t1 (v varchar(128));
|
|
insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),('a\0'),('b\''),('c\"'),('d\\'),('\'b'),('\"c'),('\\d'),('a\0\0\0b'),('a\'\'\'\'b'),('a\"\"\"\"b'),('a\\\\\\\\b'),('\'\0\\\"'),('\'\''),('\"\"'),('\\\\'),('The\ZEnd');
|
|
select * from t1 procedure analyse();
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.v " \\ 1 19 0 0 3.7619 NULL ENUM('"','""','"c','\'\0\\"','\'','\'\'','\'b','a\0\0\0b','a\0','a""""b','a\'\'\'\'b','abc','abc\'def\\hij"klm\0opq','a\\\\\\\\b','b\'','c"','d\\','The\ZEnd','\\','\\d','\\\\') NOT NULL
|
|
drop table t1;
|
|
create table t1 (df decimal(5,1));
|
|
insert into t1 values(1.1);
|
|
insert into t1 values(2.2);
|
|
select * from t1 procedure analyse();
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.df 1.1 2.2 13 13 0 0 1.65000 0.55000 ENUM('1.1','2.2') NOT NULL
|
|
drop table t1;
|
|
create table t1 (d double);
|
|
insert into t1 values (100000);
|
|
select * from t1 procedure analyse (1,1);
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.d 100000 100000 6 6 0 0 100000 0 MEDIUMINT(6) UNSIGNED NOT NULL
|
|
drop table t1;
|
|
create table t1 (product varchar(32), country_id int not null, year int,
|
|
profit int);
|
|
insert into t1 values ( 'Computer', 2,2000, 1200),
|
|
( 'TV', 1, 1999, 150),
|
|
( 'Calculator', 1, 1999,50),
|
|
( 'Computer', 1, 1999,1500),
|
|
( 'Computer', 1, 2000,1500),
|
|
( 'TV', 1, 2000, 150),
|
|
( 'TV', 2, 2000, 100),
|
|
( 'TV', 2, 2000, 100),
|
|
( 'Calculator', 1, 2000,75),
|
|
( 'Calculator', 2, 2000,75),
|
|
( 'TV', 1, 1999, 100),
|
|
( 'Computer', 1, 1999,1200),
|
|
( 'Computer', 2, 2000,1500),
|
|
( 'Calculator', 2, 2000,75),
|
|
( 'Phone', 3, 2003,10)
|
|
;
|
|
create table t2 (country_id int primary key, country char(20) not null);
|
|
insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
|
|
select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
|
|
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
|
|
test.t1.product Computer TV 2 8 0 0 4.2500 NULL ENUM('Computer','Phone','TV') NOT NULL
|
|
sum(profit) 10 6900 11 11 0 0 1946.2500 2867.6719 ENUM('10','275','600','6900') NOT NULL
|
|
avg(profit) 10.0000 1380.0000 16 16 0 0 394.68750000 570.20033144 ENUM('10.0000','68.7500','120.0000','1380.0000') NOT NULL
|
|
drop table t1,t2;
|