数据库中的货币建模 [英] Currency modeling in database
问题描述
一个非常天真的问题。我需要在数据库中存储货币。值和代码。要解决这个问题,人们一般做2列,一个存储值和其他代码?
A very naive question. I need to store currency in the database. Both the value and the code. To solve this, do people generally make 2 columns, one storing the value and other the code? Or is there an inbuilt type I can use?
-thanks
推荐答案
p>您将需要使用两列。我将货币金额存储在一列中,而将alpha货币代码存储在另一列中。在某些情况下,您将在单个行上有多个金额。例如运费金额和税额都可以在发票记录上。您需要决定是否使用相同的货币,或者您需要两列。
You will need to use two columns. I would store the monetary amount in one column and the alpha currency code in another column. In some cases, you will have multiple amounts on a single row. e.g. shipping amount and tax amount may both be on the invoice record. You will need to decide if these will share the same currency or if you need two columns.
您应该使用 ISO标准货币代码。
这篇关于数据库中的货币建模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!