In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
What is the role of float and double types in mysql, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
Float double Typ
1.float Typ
No result can be found in the default length of float column type. Precision must be specified.
For example, num float, insert into table (num) values (0.12); select * from table where num=0.12, empty set.
Num float (9 num 7), insert into table (num) values (0. 12); select * from table where num=0.12 will find this record.
Mysql > create table tt
-> (www.2cto.com
-> num float (9. 3)
->)
Query OK, 0 rows affected (0.03 sec)
Mysql > insert into tt (num) values (1234567.8)
ERROR 1264 (22003): Out of range value for column 'num' at row 1
Note: out of the field range, cannot be inserted
Mysql > insert into tt (num) values (123456.8)
Query OK, 1 row affected (0.00 sec)
Mysql > select * from tt
+-+
| | num |
+-+
| | 123456.797 |
+-+
1 row in set (0.00 sec)
Note: the number of decimal places is not enough, it will be filled automatically, but there is a problem that is the approximate value above.
Mysql > insert into tt (num) values (123456.867)
Query OK, 1 row affected (0.04 sec)
Mysql > select * from tt
+-+ www.2cto.com
| | num |
+-+
| | 123456.797 |
| | 123456.797 |
| | 123456.867 |
+-+
3 rows in set (0.00 sec)
Mysql > select * from tt where num=123456.867
+-+
| | num |
+-+
| | 123456.867 |
+-+
1 row in set (0.00 sec)
Mysql > insert into tt (num) values
Query OK, 1 row affected (0.04 sec)
Mysql > select * from tt
+-+
| | num |
+-+
| | 123456.797 |
| | 123456.797 |
| | 123456.867 |
| | 2.800 |
+-+
4 rows in set (0.00 sec)
Mysql > select * from tt where num=2.8
+-+ www.2cto.com
| | num |
+-+
| | 2.800 |
+-+
1 row in set (0.00 sec)
Mysql > insert into tt (num) values (2.888888)
Query OK, 1 row affected (0.00 sec)
Mysql > select * from tt
+-+
| | num |
+-+
| | 123456.797 |
| | 123456.797 |
| | 123456.867 |
| | 2.800 |
| | 2.889 |
+-+
5 rows in set (0.00 sec)
Note: if the number of decimal places exceeds, the approximate value will be taken automatically.
-
2.double Typ
Mysql > create table tt (
-> num double (9. 3)
->)
Query OK, 0 rows affected (0.02 sec)
Mysql > insert into tt (num) values (234563.9)
Query OK, 1 row affected (0.00 sec)
Www.2cto.com
Mysql > select * from tt
+-+
| | num |
+-+
| | 234563.900 |
+-+
1 row in set (0.00 sec)
Mysql > insert into tt (num) values (2345623.2)
ERROR 1264 (22003): Out of range value for column 'num' at row 1
Mysql > insert into tt (num) values (234563.2)
Query OK, 1 row affected (0.00 sec)
Mysql > select * from tt
+-+
| | num |
+-+
| | 234563.900 |
| | 234563.200 |
+-+
2 rows in set (0.00 sec)
Mysql > insert into tt (num) values
Query OK, 1 row affected (0.00 sec)
Mysql > select * from tt
+-+
| | num |
+-+
| | 234563.900 |
| | 234563.200 |
| | 2.800 |
+-+
3 rows in set (0.00 sec)
Www.2cto.com
FLOAT (M ~ D) or REAL (M ~ D) or DOUBLE PRECISION (M ~ D). Here, "(M _ (D))" indicates that the value shows a total of M-bit integers, where D-place is after the decimal point.
For example, a column defined as FLOAT (7p4) can be displayed as-999.9999. MySQL is rounded when saving the value, so if you insert 999.00009 into the FLOAT (7) column, the approximate result is 999.0001.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.