Postgres lc_numeric不能按预期工作 [英] Postgres lc_numeric not working as expected
问题描述
我在一个涉及使用丹麦数字设置(小数点分隔符是逗号)的数据库的项目中.我试图弄清楚如何将值以十进制/数字/除文本以外的任何形式存储在数据库中,但让它们保留逗号分隔符.我已将AWS Parameter组中的lc_numeric设置更新为da_DK,我在网上发现它是丹麦语言环境设置,但是值仍显示为句点而不是小数.需要进行哪些更改/这可能吗?
I'm on a project that involves a database that uses Danish numeric settings (the decimal separator is a comma). I'm trying to figure out how I can store values in the database as decimal/number/anything but text, but have them keep the comma separator. I've updated the lc_numeric setting in the AWS Parameter group to da_DK, which I found online to be the Danish locale setting, but values are still showing with the period instead of the decimal. What changes need to be made/is this possible?
例如:
CREATE TABLE test (
num NUMERIC
); // I've also tried Decimal instead of numeric
INSERT INTO test ('1,3') // error
INSERT INTO test ('1.3') // returns 1.3 when selected.
SHOW lc_numeric // returns da_DK as expected.
SELECT * FROM test; // 1.3
我在做什么错了?
注意:这是通过AWS RDS的postgres实例,任何更改都需要通过参数组"菜单而不是命令行进行.
Note: this is a postgres instance via AWS RDS, any changes need to be made via the Parameter Group menu and not via the command line.
推荐答案
lc_numeric
不会影响数字类型的字符串输入和输出格式,因此也不会影响类型转换的结果.
lc_numeric
does not influence the string input and output format of numeric types, so it also does not influence the result of type casts.
它仅影响转换函数 to_char
和 to_number
.关于小数点分隔符, lc_numeric
确定 D
格式说明符的含义.
It only influences the conversion functions to_char
and to_number
. With regard to the decimal separator, lc_numeric
determines the meaning of the D
format specifier.
这篇关于Postgres lc_numeric不能按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!