开发者

What data type should be used with money

I am creati开发者_JAVA百科ng a database table in MySQL Workbench. The table I want to create is to be able to save data which is a number with a decimal point. The data I want to save is a money value which has a decimal point for the centavos. I already created a table and the data type is decimal. However, when I checked the saved data the numbers where rounded off and the centavos where gone. What I want is that it won't change anything. It will still show the exact values. Please help.


I haven't used Workbench so I can't tell you exactly how to do it, but the definition should be DECIMAL(M,D) where M is the total number of digits, and D is the total number of digits to the right of the decimal. So in your case you want D=2, and choose M>2 as appropriate for your application. If D is set to 0 is it will round off your numbers automatically (sounds like that might be your problem).

Other than that I can't think of a good reason it wouldn't store the data properly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜