问题描述
任何人都可以深入了解PostgreSQL中的语言环境和数字类型行为吗?我们与意大利语言环境一起工作.那是逗号分隔的小数部分.在postgresql.conf
Could anybody give an insight on the locale and numeric types behaviour in PostgreSQL? We work with Italian locale. That is comma separation for decimal part. Setting in 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分隔为小数部分.
.. does nothing! It behaves in a quite appropriate way with dates and so, BUT the numeric type remains DOT separated for decimal part.
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)
编辑
在不同范围内执行语言环境时遇到问题:数据库,服务器脚本,操作系统和客户端. 决定避免任何语言环境格式,并使用en_EN语言环境.语言环境格式将仅在输出时应用,如此等等.
Having problem with implementation of locale in different scopes: db, server script, os and client side. Decided to avoid any locale formatting and use en_EN locale. The locale formatting will be applied only at the moment of output and so.
推荐答案
我引用了手册:
设置用于格式化数字的语言环境,例如to_char系列函数.
Sets the locale to use for formatting numbers, for example with the to_char family of functions.
担心这些类型格式化功能.您应该能够重现以下演示:
Concerns these type formatting functions. You should be able to reproduce the following demo:
SHOW lc_numeric;
de_AT.UTF-8
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;
SQL表达式中数字的格式不会不会随语言环境设置而改变.那太疯狂了.
The format of numbers in SQL expressions does not change with locale settings. That would be madness.
另一个需要注意的是:您知道更改postgresql.conf
后必须(至少)重新加载服务器.
On a different note: you are aware that you have to (at least) reload the server after changing postgresql.conf
.
pg_ctl reload
这篇关于语言环境设置LC_NUMERIC在PostgreSQL中如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!