简体   繁体   English

哪种类型的数据在MySQL中最好保留“十进制”?

[英]Which type of data is better to keep 'decimal' in MySQL?

I must to save decimal values (with high accuracy) in MySQL Data Base. 我必须将十进制值(高精度)保存在MySQL数据库中。 But in MySQL there are two types: decimal and numeric (see http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html ) and they require two number (first, second) and I don't know which those numbers is equal to C# type decimal in accuracy. 但是在MySQL中,有两种类型:十进制和数字(请参阅http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html ),它们需要两个数字(第一,第二个),而我不需要不知道那些数字等于C#型十进制精度。

In MySQL, DECIMAL and NUMERIC are the same. 在MySQL中, DECIMALNUMERIC相同。 You can use any of these types to store exact numeric values. 您可以使用任何这些类型来存储精确的数值。

From the link you type: 从链接中键入:

The DECIMAL and NUMERIC types store exact numeric data values. DECIMAL和NUMERIC类型存储精确的数值数据值。 These types are used when it is important to preserve exact precision, for example with monetary data. 当保留精确度非常重要时,例如使用货币数据,则使用这些类型。 In MySQL, NUMERIC is implemented as DECIMAL, so the following remarks about DECIMAL apply equally to NUMERIC. 在MySQL中,NUMERIC被实现为DECIMAL,因此以下有关DECIMAL的说明同样适用于NUMERIC。

I think they are exactly the same in most RDBMS. 我认为它们在大多数RDBMS中是完全相同的。 But maybe some day they will become different (I doubt that): 但是也许有一天它们会变得不同(我对此表示怀疑):

The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the SQL-92 Standard -- DECIMAL(s,p) must be exactly as precise as declared, while NUMERIC(s,p) must be at least as precise as declared. 在SQL-92标准中,DECIMAL(s,p)与NUMERIC(s,p)之间的差异是微妙的-DECIMAL(s,p)必须与声明的精度完全一样,而NUMERIC(s,p)必须位于至少和声明的一样精确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM