Set lc_monetary for PostgreSQL

青春壹個敷衍的年華 提交于 2019-12-11 07:19:26

问题


How do I set lc_monetary to show money (docs) data type as EUR?

I tried:

  • change postgresql.conf and set lc_monetary="de_DE.UTF-8@euro. PG will not start with this change (currently set to en_US.UTF-8)
  • do the same through pgAdmin and psql (using set) and I get ERROR: invalid value for parameter "lc_monetary"

My current collation is en_US.UTF-8.


回答1:


Locales depend on the operating system. Check what locales are available

select * 
from pg_collation
where collname ~ any(array['DE', 'FR', 'GR', 'IE'])

  collname  | collnamespace | collowner | collencoding | collcollate | collctype  
------------+---------------+-----------+--------------+-------------+------------
 en_IE      |            11 |        10 |            6 | en_IE.utf8  | en_IE.utf8
 en_IE.utf8 |            11 |        10 |            6 | en_IE.utf8  | en_IE.utf8
(2 rows)

Well, my Ubuntu does not speak German, French nor Greek but the Irish speak English and pay in euro.

set lc_monetary to "en_IE.utf8";
select 10::money;

 money  
--------
 €10.00
(1 row)

In Windows it is likely that the comp speaks German:

set lc_monetary to "de-DE";

Unfortunately, pg_collation does not show this.



来源:https://stackoverflow.com/questions/54064945/set-lc-monetary-for-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!