PostgreSQL: Which Datatype should be used for Currency?

前端 未结 6 812
盖世英雄少女心
盖世英雄少女心 2020-11-27 10:56

Seems like Money type is discouraged as described here

My application needs to store currency, which datatype shall I be using? Numeric, Money or FLOAT?

6条回答
  •  悲&欢浪女
    2020-11-27 11:25

    Numeric with forced 2 units precision. Never use float or float like datatype to represent currency because if you do, people are going to be unhappy when the financial report's bottom line figure is incorrect by + or - a few dollars.

    The money type is just left in for historical reasons as far as I can tell.

提交回复
热议问题