有没有人可以深入了解PostgreSQL中的语言环境和数字类型行为?我们与意大利语语言环境合作。这是小数部分的逗号分隔。在postgresql.conf
# These settings are initialized by initdb, but they can be changed.
lc_messages = 'it_IT.UTF-8' # locale for system error message
# strings
lc_monetary = 'it_IT.UTF-8' # locale for monetary formatting
lc_numeric = 'it_IT.UTF-8' # locale for number formatting
lc_time = 'it_IT.UTF-8' # locale for time formatting
..什么都不做!它以一种非常合适的方式表现日期,所以,但数字类型仍然是DOT分开的小数部分。
root@server:~# uname -a
Linux server 2.6.32-36-generic-pae #79-Ubuntu SMP Tue Nov 8 23:25:26 UTC 2011 i686 GNU/Linux
root@server:~# dpkg -l | grep postgresql
ii postgresql-8.4 8.4.9-0ubuntu0.10.04 object-relational SQL database, version 8.4
ii postgresql-client 8.4.9-0ubuntu0.10.04 front-end programs for PostgreSQL (supported)
修改
在不同范围内实现locale有问题:db,server script,os和client side。 决定避免使用任何区域设置格式并使用en_EN区域设置。区域设置格式化仅在输出时应用。
答案 0 :(得分:6)
我引用manual:
lc_numeric(string)
设置用于格式化数字的语言环境,例如使用to_char系列函数。
关注这些type formatting functions。您应该能够重现以下演示:
SHOW lc_numeric;
de_AT.UTF-8
SELECT to_number('13,4','999D99')
13.4
SELECT to_char(13.4,'FM999D99')
13,4
SET lc_numeric = 'C';
SELECT to_number('13,4','999D99')
134
SELECT to_char(13.4,'FM999D99')
13.4
RESET lc_numeric;
Template patterns in the manual
SQL表达式中的数字格式不随区域设置而变化。那将是疯狂的。
另请注意:您知道在更改postgresql.conf
后必须(至少)重新加载服务器。
pg_ctl reload