zoukankan      html  css  js  c++  java
  • MySQL DECIMAL类型

    mysql> use test;
    Database changed

    mysql> create table teacher(score decimal(6, 2));
    Query OK, 0 rows affected (0.04 sec)

    mysql> insert into teacher values(34.35464), (23534523.45434), ('3223.3557');
    Query OK, 3 rows affected, 3 warnings (0.04 sec)
    Records: 3  Duplicates: 0  Warnings: 3

    mysql> select * from teacher;
    +---------+
    | score   |
    +---------+
    |   34.35 |
    | 9999.99 |
    | 3223.36 |
    +---------+
    3 rows in set (0.00 sec)

    # decimal存储负数
    mysql> insert into teacher values(-4508.90764); Query OK, 1 row affected, 1 warning (0.08 sec) mysql> select * from teacher; +----------+ | score | +----------+ | 34.35 | | 9999.99 | | 3223.36 | | -4508.91 | +----------+ 4 rows in set (0.00 sec) mysql>
    # decimal中以字符串存储'7956.54768'
    
    mysql> insert into teacher values('7956.54768'); Query OK, 1 row affected, 1 warning (0.04 sec) mysql> select * from teacher; +----------+ | score | +----------+ | 34.35 | | 9999.99 | | 3223.36 | | -4508.91 | | 7956.55 | +----------+ 5 rows in set (0.00 sec) mysql>

    (1)DECIMAL 类型不同于FLOAT和DOUBLE,其中DECIMAL 实际是以串存放的。

    (2)DECIMAL(6, 2) 能够表示从-9999.99 到9999.99 的所有值,而且存储符号和小数点。

  • 相关阅读:
    实现一个最简单的flask应用程序
    python常识
    Flex布局
    ES6的promise的学习
    通过正则获取url参数
    dom0级事件和dom2级事件
    sea.js总结
    跨域的几种方式
    人生苦短,生命也就一次,机会也就一次
    新开的博客先和大家打个招呼吧!
  • 原文地址:https://www.cnblogs.com/Robotke1/p/3054933.html
Copyright © 2011-2022 走看看