• 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 的所有值,而且存储符号和小数点。

  • 相关阅读:
    re模块---正则表达式
    configparser 配置文件模块
    svn服务器配置
    python中的list的方法
    python正则表达式
    os模块
    高阶函数
    递归
    推导式
    [转]Java中的多线程你只要看这一篇就够了
  • 原文地址:https://www.cnblogs.com/Robotke1/p/3054933.html
Copyright © 2020-2023  润新知