在 MySQL 中更改小数点分隔符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8669212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change decimal separator in MySQL
提问by TMS
Is it possible to change the decimal comma from "." (dot) to other character (comma) in MySQL output? I don't want to use functions like FORMAT
, I just want to use all the queries I normaly use without any modification. I'm looking for some setting (of some variable, locale etc.). I tried to search the manual but without success.
是否可以将十进制逗号从“。”更改为 (点)到 MySQL 输出中的其他字符(逗号)?我不想使用像 那样的函数FORMAT
,我只想使用我通常使用的所有查询而无需任何修改。我正在寻找一些设置(一些变量、语言环境等)。我试图搜索手册,但没有成功。
采纳答案by ypercube??
No, you can't. That's the SQL standard and MySQL complies with it (in that point at least).
不,你不能。这是 SQL 标准,MySQL 遵守它(至少在这一点上)。
The problem is not really with output (as you mention, there are various FORMAT
functions in most DBMSs) but with INSERT
. If you could use comma ,
for example as decimal point (that's common in other locales) which is aslo used as values separator, Inserts would become ambiguous. See my answer in the question: insert-non-english-decimal-points-in-mysql
问题不在于输出(正如您所提到的,FORMAT
大多数 DBMS 中都有各种功能),而在于INSERT
. ,
例如,如果您可以使用逗号作为小数点(这在其他语言环境中很常见),它也用作值分隔符,则插入将变得不明确。请参阅我在问题中的回答:insert-non-english-decimal-points-in-mysql
回答by Ome Ko
Tip for CSV exports:
SELECT REPLACE(CAST(prijs_incl AS CHAR), '.', ',')
will give you input that can be used as numeric fields in european excelsheets.
CSV 导出提示:
SELECT REPLACE(CAST(prijs_incl AS CHAR), '.', ',')
将为您提供可用作欧洲 Excel 表格中数字字段的输入。