Li
Delete
Are you sure you want to delete this?
CntanzModel
-
Date
-
20220127
-
Target
-
C_032
-
Title
-
MS SQL Currency datatype 무엇이 좋은가?
-
Contents
-
영문사이트를 만들면서 달라 통화에 어떤 데이터 타이프를 사용하는 것이 좋을지에 대한 의문이 생겼다.
현재 Decimal(18)이다. 이것을 어떻게 바꾸어야 좋을까?
https://stackoverflow.com/questions/582797/should-you-choose-the-money-or-decimalx-y-datatypes-in-sql-server
에 의하면 Never ever should you use money. It is not precise, and it is pure garbage; always use decimal/numeric. 라는 조언을 하고 있다.
댓글에
"Never" is a strong word. "Money" is useful for casting results to that type for display to the user in a culture-sensitive way, but you're right that it's very bad to use for the calculations itself. –
Joel Coehoorn
Feb 24 '09
라고 되어 있어 타당성이 인정된다.
https://stackoverflow.com/questions/628637/best-data-type-for-storing-currency-values-in-a-mysql-database에는
Something like Decimal(19,4) usually works pretty well in most cases. You can adjust the scale and precision to fit the needs of the numbers you need to store. Even in SQL Server, I tend not to use "money" as it's non-standard. 로 설명되고 있다.
추가로
What is the benefit to using (19,4) instead of (19,2)? –
ryvantage
Oct 25 '16 at 20:54
2
My benefit was this.. I needed all my table rows to equal a particular amount of money. Let's say that amount is $10.00. As new rows get added each row amount changes. If there are 3 rows in the table. 10 / 3 = 3.3333333333... but with only 2 decimals they are stored as 3.33. So when you sum those up, 3.33 + 3.33 + 3.33 = 9.99. We lost a penny! Gets even worse on a larger dataset. Store at 19,4 and sum your totals, then round the output to 19,2.. –
Rick
Feb 16 '18 at 3:23
좋은 설명이 있는 website : https://www.mysqltutorial.org/mysql-decimal/