mysql float double 类型
来源:互联网 发布:淘宝客服用什么软件 编辑:程序博客网 时间:2024/05/17 05:19
1.float类型
float列类型默认长度查不到结果,必须指定精度,
比如 num
num float(9,7),
mysql> create table tt
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
注:超出字段范围,无法插入
mysql> insert into tt(num)values(123456.8);
Query OK, 1 row affected (0.00 sec)
mysql> select
+------------+
| num
+------------+
| 123456.797 |
+------------+
1 row in set (0.00 sec)
注:小数位数不够,自动补齐,但是存在一个问题就是如上的近似值。
mysql> insert into tt(num)values(123456.867);
Query OK, 1 row affected (0.04 sec)
mysql> select * from
+------------+
| num
+------------+
| 123456.797 |
| 123456.797 |
| 123456.867 |
+------------+
3 rows in set (0.00 sec)
mysql> select
+------------+
| 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
+------------+
| num
+------------+
| 123456.797 |
| 123456.797 |
| 123456.867 |
|
+------------+
4 rows in set (0.00 sec)
mysql> select
+-------+
| 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
+------------+
| num
+------------+
| 123456.797 |
| 123456.797 |
| 123456.867 |
|
|
+------------+
5 rows in set (0.00 sec)
注:小数位数超了,自动取近似值。
--------------------------------------------------------------------------------------
2.double类型
mysql> create table tt(
Query OK, 0 rows affected (0.02 sec)
mysql> insert into tt(num) values(234563.9);
Query OK, 1 row affected (0.00 sec)
mysql> select * from
+------------+
| 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
+------------+
| 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
+------------+
| num
+------------+
| 234563.900 |
| 234563.200 |
|
+------------+
3 rows in set (0.00 sec)
FLOAT(M,D)或REAL(M,D)或DOUBLE PRECISION(M,D)。这里,“(M,D)”表示该值一共显示M位整数,其中D位位于小数点后面。
例如,定义为FLOAT(7,4)的一个列可以显示为-999.9999。MySQL保存值时进行四舍五入,因此如果在FLOAT(7,4)列内插入999.00009,近似结果是999.0001。
- mysql float double 类型
- mysql float double 类型
- mysql float double 类型
- mysql float double 类型
- mysql小数类型字段,float,double
- MYSQL中的FLOAT、DOUBLE和DECIMAL类型
- mysql float和double类型的区别
- MySQL中的float、double和decimal类型
- MySQL数值类型——FLOAT、DOUBLE和DECIMAL类型
- c++ float/double 类型
- MySQL中Decimal类型和Float Double等区别
- MySQL中Decimal类型和Float Double等区别
- double float 类型的输出
- float,double和decimal类型
- float,double和decimal类型
- Int,long,float,double类型
- float,double和decimal类型
- float,double和decimal类型
- 8皇后问题--回溯法 (循环递归)
- Sqlite数据类型
- 解决:<net.sf.ehcache.util.UpdateChecker> : New update(s) found: 2.6.5
- Google服务全线被封:附解决方案
- AbstractQueuedSynchronizer实现源码解析(一)
- mysql float double 类型
- ipsec.conf(5) - Linux man page
- 如何写music apk
- WinForm_DataGridView一列多个按钮
- 简单网络爬虫Ruby版
- 【AndEngine游戏开发】第一章:2.选择我们的引擎类型
- 中等难度通讯录
- 不是所有的邮件中继转发服务都叫易安特
- 一个简单的CI分页类