gpt4 book ai didi

MySQL:(产品)价格的首选列类型?

转载 作者:IT老高 更新时间:2023-10-28 12:53:08 30 4
gpt4 key购买 nike

在 MySQL 中,存储产品价格(或一般货币)的首选列类型是什么?谷歌知道我经常使用 DECIMAL of FLOAT,但我想知道哪个更好。

我存储的价格范围是 0.01 到 25.00。当然更高的值也是可能的。 (注意:我不是要求复制意大利面代码,我只是为您提供更多信息,可以帮助您形成更完整的答案)。

谢谢

最佳答案

十进制是我会使用的

The basic difference between Decimal/Numeric and Float : Float is Approximate-number data type, which means that not all values in the data type range can be represented exactly. Decimal/Numeric is Fixed-Precision data type, which means that all the values in the data type reane can be represented exactly with precision and scale.

Converting from Decimal or Numeric to float can cause some loss of precision. For the Decimal or Numeric data types, SQL Server considers each specific combination of precision and scale as a different data type. DECIMAL(4,2) and DECIMAL(6,4) are different data types. This means that 11.22 and 11.2222 are different types though this is not the case for float. For FLOAT(6) 11.22 and 11.2222 are same data types.

关于MySQL:(产品)价格的首选列类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1796334/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com