📄 type_float.result
字号:
drop table if exists t1,t2;SELECT 10,10.0,10.,.1e+2,100.0e-1;10 10.0 10. .1e+2 100.0e-110 10.0 10 10 10SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;6e-05 -6e-05 --6e-05 -6e-05+1.0000006e-05 -6e-05 6e-05 0.99994SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-110 10 10 10 10 10 0.1 0.1 0.1SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01;0.001e+1 0.001e-1 -0.001e+01 -0.001e-010.01 0.0001 -0.01 -0.0001SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0;123.23E+02 -123.23E-02 "123.23E+02"+0.0 "-123.23E-02"+0.012323 -1.2323 12323 -1.2323SELECT 2147483647E+02,21474836.47E+06;2147483647E+02 21474836.47E+06214748364700 21474836470000create table t1 (f1 float(24),f2 float(52));show full columns from t1;Field Type Collation Null Key Default Extra Privileges Commentf1 float NULL YES NULL # f2 double NULL YES NULL # insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);Warnings:Warning 1264 Out of range value adjusted for column 'f1' at row 7Warning 1264 Out of range value adjusted for column 'f1' at row 8insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);select * from t1;f1 f210 10100000 1000001.23457e+09 12345678901e+10 100000000001e+15 1e+151e+20 1e+203.40282e+38 1e+503.40282e+38 1e+150-10 -101e-05 1e-051e-10 1e-101e-15 1e-151e-20 1e-200 1e-500 1e-150drop table t1;create table t1 (datum double);insert into t1 values (0.5),(1.0),(1.5),(2.0),(2.5);select * from t1;datum0.511.522.5select * from t1 where datum < 1.5;datum0.51select * from t1 where datum > 1.5;datum22.5select * from t1 where datum = 1.5;datum1.5drop table t1;create table t1 (a decimal(7,3) not null, key (a));insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");select a from t1 order by a;a-0.010-0.0020.0000.0001.000select min(a) from t1;min(a)-0.010drop table t1;create table t1 (c1 double, c2 varchar(20));insert t1 values (121,"16");select c1 + c1 * (c2 / 100) as col from t1;col140.36create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1;select * from t2;col1 col2 col3 col4140.36 121.00000 121 3.47850542618522e-07show create table t2;Table Create Tablet2 CREATE TABLE `t2` ( `col1` double default NULL, `col2` double(53,5) default NULL, `col3` double default NULL, `col4` double default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1drop table t1,t2;create table t1 (a float);insert into t1 values (1);select max(a),min(a),avg(a) from t1;max(a) min(a) avg(a)1 1 1drop table t1;create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(7,6));show full columns from t1;Field Type Collation Null Key Default Extra Privileges Commentf float NULL YES NULL # f2 float NULL YES NULL # f3 float(6,2) NULL YES NULL # d double NULL YES NULL # d2 double NULL YES NULL # d3 double(10,3) NULL YES NULL # de decimal(10,0) NULL YES NULL # de2 decimal(6,0) NULL YES NULL # de3 decimal(5,2) NULL YES NULL # n decimal(10,0) NULL YES NULL # n2 decimal(8,0) NULL YES NULL # n3 decimal(7,6) NULL YES NULL # drop table t1;create table t1 (a decimal(7,3) not null, key (a));insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");select a from t1 order by a;a-0.010-0.0020.0000.0001.000select min(a) from t1;min(a)-0.010drop table t1;create table t1 (a float(200,100), b double(200,100));ERROR 42000: Too big scale 100 specified for column 'a'. Maximum is 30.create table t1 (c20 char);insert into t1 values (5000.0);Warnings:Warning 1265 Data truncated for column 'c20' at row 1insert into t1 values (0.5e4);Warnings:Warning 1265 Data truncated for column 'c20' at row 1drop table t1;create table t1 (f float(54));ERROR 42000: Incorrect column specifier for column 'f'drop table if exists t1;create table t1 (d1 double, d2 double unsigned);insert into t1 set d1 = -1.0;update t1 set d2 = d1;Warnings:Warning 1264 Out of range value adjusted for column 'd2' at row 1select * from t1;d1 d2-1 0drop table t1;create table t1 (f float(4,3));insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");Warnings:Warning 1264 Out of range value adjusted for column 'f' at row 1Warning 1264 Out of range value adjusted for column 'f' at row 2Warning 1264 Out of range value adjusted for column 'f' at row 3Warning 1264 Out of range value adjusted for column 'f' at row 4Warning 1264 Out of range value adjusted for column 'f' at row 5Warning 1264 Out of range value adjusted for column 'f' at row 6select * from t1;f-9.999-9.999-9.9999.9999.9999.999drop table if exists t1;create table t1 (f double(4,3));insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");Warnings:Warning 1264 Out of range value adjusted for column 'f' at row 1Warning 1264 Out of range value adjusted for column 'f' at row 2Warning 1264 Out of range value adjusted for column 'f' at row 3Warning 1264 Out of range value adjusted for column 'f' at row 4Warning 1264 Out of range value adjusted for column 'f' at row 5Warning 1264 Out of range value adjusted for column 'f' at row 6select * from t1;f-9.999-9.999-9.9999.9999.9999.999drop table if exists t1;create table t1 (c char(20));insert into t1 values (5e-28);select * from t1;c5e-28drop table t1;create table t1 (c char(6));insert into t1 values (2e5),(2e6),(2e-4),(2e-5);select * from t1;c2000002e+060.00022e-05drop table t1;CREATE TABLE t1 (reckey int unsigned NOT NULL,recdesc varchar(50) NOT NULL,PRIMARY KEY (reckey)) ENGINE=MyISAM DEFAULT CHARSET=latin1;INSERT INTO t1 VALUES (108, 'Has 108 as key');INSERT INTO t1 VALUES (109, 'Has 109 as key');select * from t1 where reckey=108;reckey recdesc108 Has 108 as keyselect * from t1 where reckey=1.08E2;reckey recdesc108 Has 108 as keyselect * from t1 where reckey=109;reckey recdesc109 Has 109 as keyselect * from t1 where reckey=1.09E2;reckey recdesc109 Has 109 as keydrop table t1;create table t1 (d double(10,1));create table t2 (d double(10,9));insert into t1 values ("100000000.0");insert into t2 values ("1.23456780");create table t3 select * from t2 union select * from t1;select * from t3;d1.234567800100000000.000000000show create table t3;Table Create Tablet3 CREATE TABLE `t3` ( `d` double(22,9) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1drop table t1, t2, t3;create table t1 select 105213674794682365.00 + 0.0 x;show warnings;Level Code Messagedesc t1;Field Type Null Key Default Extrax decimal(21,2) unsigned NO 0.00 drop table t1;create table t1 select 0.0 x;desc t1;Field Type Null Key Default Extrax decimal(2,1) unsigned NO 0.0 create table t2 select 105213674794682365.00 y;desc t2;Field Type Null Key Default Extray decimal(20,2) unsigned NO 0.00 create table t3 select x+y a from t1,t2;show warnings;Level Code Messagedesc t3;Field Type Null Key Default Extraa decimal(21,2) unsigned NO 0.00 drop table t1,t2,t3;create table t1 (s1 float(0,2));ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').create table t1 (s1 float(1,2));ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -