Mysql float double Type

Source: Internet
Author: User
Tags float double


Mysql float double type 1. float Type float column type default length cannot be found, you must specify the precision, such as num float, insert into table (num) values (0.12); select * from table where num = 0.12, empty set. Num float (0.12), insert into table (num) values (0.12); select * from table where num = will find this record. Mysql> create table tt-> (www.2cto.com-> num float (0.03)->); Query OK, 0 rows affected (sec) mysql> insert into tt (num) values (1234567.8); ERROR 1264 (22003): Out of range value for column 'num' at row 1 Note: mysql> insert into tt (num) cannot be inserted because it is Out of the field range) values (123456.8); Query OK, 1 row affected (0.00 sec) mysql> select * from tt; + ------------ + | num | + ------------ + | 123456.797 | + ------------ + 1 row in se T (0.00 sec) Note: The number of decimal places is not enough and the number of digits is automatically filled up. However, there is a problem with the approximate values 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 (2.8); 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> selec T * 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 upper limit, the approximate value is automatically obtained. Limit 2. double mysql> create table tt (-> num double (0.02)->); Query OK, 0 rows affected (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 I Nto 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 (2.8 ); 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 displays a total of M-bit integers, where D is behind the decimal point. For example, a column defined as FLOAT (999.9999) can be displayed. MySQL returns a rounded value when saving the value. Therefore, if 999.00009 is inserted in the FLOAT (999.0001) column, the approximate result is. Author chow _ zh

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.