开发者

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

开发者 https://www.devze.com 2023-04-11 17:04 出处:网络
I must to save decimal values (with high accuracy) in MySQL Data Base. But in MySQL there are two types: decimal and numer开发者_StackOverflow社区ic (see http://dev.mysql.com/doc/refman/5.0/en/numeric

I must to save decimal values (with high accuracy) in MySQL Data Base. But in MySQL there are two types: decimal and numer开发者_StackOverflow社区ic (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.


From the link you type:

The DECIMAL and NUMERIC types store exact numeric data values. 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.

I think they are exactly the same in most 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.


In MySQL, DECIMAL and NUMERIC are the same. You can use any of these types to store exact numeric values.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号