在postgresql中存储货币符号的最佳方法是什么?

时间:2017-06-07 21:24:28

标签: postgresql

我需要创建货币符号列并尝试将其保存为具有unicode值的bytea,但我在数据库管理器(intellij)中将其视为原始代码,而不是实际的符号字符。 什么是最好和最可接受的方式?

1 个答案:

答案 0 :(得分:0)

我必须完全忽视这一点,因为我只会:

x=# with utf(sign,currency) as (values(e'\u20BD','Rubble'),(e'\u20AC','Euro'),(e'\u20AF','Drachma'))
select *,pg_typeof(sign) from utf;
 sign | currency | pg_typeof
------+----------+-----------
 ₽    | Rubble   | text
 €    | Euro     | text
 ₯    | Drachma  | text
(3 rows)

取自https://www.w3schools.com/charsets/ref_utf_currency.asp

的UTF代码

最初也想要使用postgres内部货币类型,因为它将符号放在正确的位置(金额之前或之后),但在印地语区域失败:

x=# set lc_monetary TO 'hi_IN';
ERROR:  invalid value for parameter "lc_monetary": "hi_IN"
Time: 0.332 ms
x=# set lc_monetary TO 'EN_ie';
SET
Time: 0.514 ms
x=# select 1::money;
 money
-------
 €1.00
(1 row)

Time: 3.313 ms
x=# set lc_monetary TO 'RU_ru';
SET
Time: 10.178 ms
x=# select 1::money;
   money
-----------
 1,00 руб.
(1 row)
相关问题