Windows 10上的PostgreSQL。语言环境已损坏

时间:2019-09-26 18:59:57

标签: windows postgresql locale

我已经在Windows 10 PC上安装了PostgreSQL版本11两次。第一次来自Windows的官方安装程序,第二次来自cygwin的一组软件包。

问题是,我无法获得任何数据库区域设置来正常工作。在以上两种情况中的任何一种情况下,Postgres集群都是使用initdb命令初始化的。

在安装cygwin的情况下,该命令具有-E UTF8--locale=uk_UA.utf8,并且对于collationctypes来说,该命令也相同。 cygwin似乎可以识别命令,集群已创建。然后,我用适当的设置和其中的一些表创建了数据库。

对于我的语言环境,简单查询的输出是完全错误的。货币符号是$而不是грн.是分数的,等等。官方安装程序给出了相同的结果,并且设置了语言环境并正确显示。

initdbcreate database相同,linux OS给我正确的结果。

initdb

initdb —pgdata=... \
          —locale=uk_UA.utf8
          —lc-collate=...
          —lc-type=...
          —lc-monetary=...
          —lc-numeric=...
          —lc-time=...
          —encoding=UTF-8

基本上,我在这里重复了uk_UA.utf8语言环境。 还尝试使用“ uk-x-icu”语言环境,因为Windows版本似乎是用icu库编译的。

查询

create database db
 template         = template0
 encoding         = 'UTF8'
 lc_collate       = 'uk_UA.utf8'
 ...              = 'uk_UA.utf8'
 lc_ctype         = 'uk_UA.utf8'
 connection_limit = -1
 is_template      = false
;

create table c_types (
 id           serial,
 c_date       date,
 c_text       text,
 c_time       time,
 c_timestamp  timestamp,
 c_money      money,
 c_float      float
);

insert into c_types(c_date,c_text,c_time,c_timestamp,c_money,c_float) values
('2019-09-01', 'text0', '00:00:01', timestamp '2019-09-01 20:00:00', 1000.0001, 1000.0001),
('2019-09-01', 'text1', '00:00:02', timestamp '2019-09-01 21:00:00', 2000.0001, 2000.0001)
;

select * from c_types;

正确的输出(Linux)

# id |   c_date   | c_text |  c_time  |     c_timestamp     |    c_money    |  c_float  
#----+------------+--------+----------+---------------------+---------------+-----------
#  1 | 2019-09-01 | text0  | 00:00:01 | 2019-09-01 20:00:00 |  1 000,00грн. | 1000.0001
#  2 | 2019-09-01 | text1  | 00:00:02 | 2019-09-01 21:00:00 |  2 000,00грн. | 2000.0001

这篇文章显示lc_numeric不会按原样影响数字中的分隔符 https://stackoverflow.com/a/41759744/8339821

受影响的功能是to_numberto_char https://stackoverflow.com/a/8935028/8339821

问题是,如何为我的语言环境设置Postgres?

0 个答案:

没有答案