mysql命令行float 设置整数

mysql> create table one(
    -> id float(3,1)
    -> )engine=myisam default charset=utf8;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into one (id)values (44.44);
Query OK, 1 row affected (0.00 sec)

mysql> select * from one;
+------+
| id   |
+------+
| 44.4 |
+------+
1 row in set (0.00 sec)                               //这里正常可以明白

mysql> create table two(
    -> id float(5,2)
    -> )engine=myisam default charset=utf8;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into two (id) values(34567.6789);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from two;
+--------+
| id     |
+--------+
| 999.99 |
+--------+
1 row in set (0.00 sec)     //这里填充5位整数 而float设置为3位字符受到破坏 所以导致出现999.99
                                                                         
mysql> create table gree(
    -> id float(5,2)
    -> )engine=myisam default charset=utf8;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into gree(id) values(999.446);
Query OK, 1 row affected (0.00 sec)

mysql> select * from gree;              //下面可以理解啦
+--------+
| id     |
+--------+
| 999.45 |
+--------+
1 row in set (0.00 sec)

mysql> create table four(
    -> id float (5,2)
    -> )engine=myisam default charset=utf8;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into four (id) values(99.123);
Query OK, 1 row affected (0.00 sec)

mysql> select * from four;
+-------+
| id    |
+-------+
| 99.12 |
+-------+
1 row in set (0.00 sec)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值