Igo*_*gor 3 php postgresql locale
任何人都可以深入了解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
Run Code Online (Sandbox Code Playgroud)
.. 什么也没做!它以一种非常合适的方式表现日期,因此,但数字类型仍为小数部分分开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)
Run Code Online (Sandbox Code Playgroud)
编辑
在不同范围内实现locale有问题:db,server script,os和client side.决定避免任何区域设置格式并使用en_EN语言环境.区域设置格式仅在输出时应用.
我引用手册:
lc_numeric(string)
设置用于格式化数字的语言环境,例如使用to_char系列函数.
关注这些类型格式化功能.您应该能够重现以下演示:
SHOW lc_numeric;
Run Code Online (Sandbox Code Playgroud)
de_AT.UTF-8
SELECT to_number('13,4','999D99')
Run Code Online (Sandbox Code Playgroud)
13.4
SELECT to_char(13.4,'FM999D99')
Run Code Online (Sandbox Code Playgroud)
13,4
SET lc_numeric = 'C';
SELECT to_number('13,4','999D99')
Run Code Online (Sandbox Code Playgroud)
134
SELECT to_char(13.4,'FM999D99')
Run Code Online (Sandbox Code Playgroud)
13.4
RESET lc_numeric;
Run Code Online (Sandbox Code Playgroud)
SQL表达式中的数字格式不会随语言环境设置而改变.那将是疯狂的.
另请注意:您知道在更改后必须(至少)重新加载服务器postgresql.conf.
pg_ctl reload
Run Code Online (Sandbox Code Playgroud)