PostgreSQL: Which Datatype should be used for Currency?

前端 未结 6 802
盖世英雄少女心
盖世英雄少女心 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:27

    Use BigInt to store currency as a positive integer representing the monetary value in the smallest currency unit (e.g., 100 cents to store $1.00 or 100 to store ¥100 (Japanese yen, a zero-decimal currency). This is what Stripe does--one the most important financial service companies for global ecommerce.

提交回复
热议问题