(used_gas   decimal(2,0) unsigned);

(used_gas   float(2,0)   unsigned);
从DB侧来判断,应该是不相等的,
它们的不同点,也就是说,为什么不相等,
能不能解释说明一下.
谢谢.

解决方案 »

  1.   

    decimal与numeric是同义的,她们是用来精确存储数值的;
    float和real是同义的,她们不能精确存储数值.decimal数据类型最多可存储 38 个数字,它存储了一个准确(精确)的数字表达法,不存储值的近似值。
    numeric和decimal数据类型的默认最大精度值是 38。在 Transact-SQL 中,numeric与decimal数据类型在功能上等效。
    当数据值一定要按照指定精确存储时,可以用带有小数的decimal数据类型来存储数字。float和real数据类型被称为近似的数据类型。不存储精确值.当要求精确的数字状态时,比如在财务应用程序中,在那些需要舍入的操作中,或在等值核对的操作中,就不使用这些数据类型。这时就要用integer、decimal、money或smallmone数据类型。
    在 WHERE 子句搜索条件中(特别是 = 和 <> 运算符),应避免使用float或real列。最好限制使用float和real列做> 或 < 的比较。
    就是这么个意思了大体上,从感性的角度理解,就是这样了.
      

  2.   

    1 楼正解。http://dev.mysql.com/doc/refman/5.1/zh/column-types.html#numeric-types
      

  3.   

    实际上就是精度不同,在MYSQL HELP中有解释
      

  4.   

    你可以下一本mysql的手册好好看看,在mysql5.1手册的第11章,你看看,其实就是精度不同
    http://download.csdn.net/source/1087691
      

  5.   

    对mysql 5来说
    decimal(p,s)中p最大为65,S最大为30
    mysql保存这个数据的时候是把小数点前和小数点后分别保存,你可以理解为用字符串的形式保存
    带来的好处是精确,没有不同进制之间小数转换带来的误差
    坏处是计算会慢一点
      

  6.   

    没太大区别,但是DECIMAL,5.0.3 版本才开始有Name: 'FLOAT'
    Description:
    FLOAT[(M,D)] [UNSIGNED] [ZEROFILL]A small (single-precision) floating-point number. Allowable values are
    -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to
    3.402823466E+38. These are the theoretical limits, based on the IEEE
    standard. The actual range might be slightly smaller depending on your
    hardware or operating system.Name: 'DECIMAL'
    Description:
    DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]For MySQL 5.0.3 and above:A packed "exact" fixed-point number. M is the total number of digits
    (the precision) and D is the number of digits after the decimal point
    (the scale). The decimal point and (for negative numbers) the "-" sign
    are not counted in M. If D is 0, values have no decimal point or
    fractional part. The maximum number of digits (M) for DECIMAL is 65 (64
    from 5.0.3 to 5.0.5). The maximum number of supported decimals (D) is
    30. If D is omitted, the default is 0. If M is omitted, the default is
    10.