8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 12 种字符集、排序规则、Unicode / 12.16 MySQL 服务器区域设置支持
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 72%

12.16 MySQL 服务器区域设置支持12.16 MySQL Server Locale Support

lc_time_names 系统变量指定的区域设置控制用于显示星期和月份名称及其缩写的语言。该变量会影响 DATE_FORMAT()、DAYNAME() 和 MONTHNAME() 函数的输出。The locale indicated by the lc_time_names system variable controls the language used to display day and month names and abbreviations. This variable affects the output from the DATE_FORMAT(), DAYNAME(), and MONTHNAME() functions.

lc_time_names 不会影响 STR_TO_DATE() 或 GET_FORMAT() 函数。lc_time_names does not affect the STR_TO_DATE() or GET_FORMAT() function.

lc_time_names 的值不会影响 FORMAT() 的结果,但该函数接受一个可选的第三个参数,用于指定用于结果数字的十进制点、千位分隔符以及分隔符之间分组的区域设置。允许的区域设置值与 lc_time_names 系统变量的合法值相同。The lc_time_names value does not affect the result from FORMAT(), but this function takes an optional third parameter that enables a locale to be specified to be used for the result number's decimal point, thousands separator, and grouping between separators. Permissible locale values are the same as the legal values for the lc_time_names system variable.

区域名称具有由 IANA 列出的语言和地区子标签(http://www.iana.org/assignments/language-subtag-registry),例如 'ja_JP' 或 'pt_BR'。默认值是 'en_US',不管您的系统区域设置如何,但您可以在服务器启动时设置该值,或者如果您有足够权限设置全局系统变量,也可以在运行时设置 GLOBAL 值;参见 第 7.1.9.1 节,“系统变量权限”。任何客户端都可以查看 lc_time_names 的值,或者设置其 SESSION 值以影响自身连接的区域设置。Locale names have language and region subtags listed by IANA (http://www.iana.org/assignments/language-subtag-registry) such as 'ja_JP' or 'pt_BR'. The default value is 'en_US' regardless of your system's locale setting, but you can set the value at server startup, or set the GLOBAL value at runtime if you have privileges sufficient to set global system variables; see Section 7.1.9.1, “System Variable Privileges”. Any client can examine the value of lc_time_names or set its SESSION value to affect the locale for its own connection.

(下面示例中的第一个 SET NAMES 语句可能不是必需的,如果没有修改与字符集和排序规则相关的设置;我们为了完整性将其包括在内。)(The first SET NAMES statement in the following example may not be necessary if no settings relating to character set and collation have been changed from their defaults; we include it for completeness.)

mysql> SET NAMES 'utf8mb4';
Query OK, 0 rows affected (0.09 sec)

mysql> SELECT @@lc_time_names;
+-----------------+
| @@lc_time_names |
+-----------------+
| en_US           |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT DAYNAME('2020-01-01'), MONTHNAME('2020-01-01');
+-----------------------+-------------------------+
| DAYNAME('2020-01-01') | MONTHNAME('2020-01-01') |
+-----------------------+-------------------------+
| Wednesday             | January                 |
+-----------------------+-------------------------+
1 row in set (0.00 sec)

mysql> SELECT DATE_FORMAT('2020-01-01','%W %a %M %b');
+-----------------------------------------+
| DATE_FORMAT('2020-01-01','%W %a %M %b') |
+-----------------------------------------+
| Wednesday Wed January Jan               |
+-----------------------------------------+
1 row in set (0.00 sec)

mysql> SET lc_time_names = 'es_MX';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @@lc_time_names;
+-----------------+
| @@lc_time_names |
+-----------------+
| es_MX           |
+-----------------+
1 row in set (0.00 sec)

mysql> SELECT DAYNAME('2020-01-01'), MONTHNAME('2020-01-01');
+-----------------------+-------------------------+
| DAYNAME('2020-01-01') | MONTHNAME('2020-01-01') |
+-----------------------+-------------------------+
| miércoles             | enero                   |
+-----------------------+-------------------------+
1 row in set (0.00 sec)

mysql> SELECT DATE_FORMAT('2020-01-01','%W %a %M %b');
+-----------------------------------------+
| DATE_FORMAT('2020-01-01','%W %a %M %b') |
+-----------------------------------------+
| miércoles mié enero ene                 |
+-----------------------------------------+
1 row in set (0.00 sec)

每个受影响函数的日期或月份名称将从 utf8mb4 转换为由 character_set_connection 系统变量指定的字符集。The day or month name for each of the affected functions is converted from utf8mb4 to the character set indicated by the character_set_connection system variable.

lc_time_names 可以设置为以下任何区域设置值。MySQL 支持的区域设置集合可能与您的操作系统支持的有所不同。lc_time_names may be set to any of the following locale values. The set of locales supported by MySQL may differ from those supported by your operating system.

区域值Locale Value 意义Meaning
ar_AEar_AE 阿拉伯语 - 阿拉伯联合酋长国Arabic - United Arab Emirates
ar_BHar_BH 阿拉伯语 - 巴林Arabic - Bahrain
ar_DZar_DZ 阿拉伯语 - 阿尔及利亚Arabic - Algeria
ar_EGar_EG 阿拉伯语 - 埃及Arabic - Egypt
ar_IN 阿拉伯语 - 印度Arabic - India
ar_IQar_IQ 阿拉伯语 - 伊拉克Arabic - Iraq
ar_JOar_JO 阿拉伯语 - 约旦Arabic - Jordan
ar_KWar_KW 阿拉伯语 - 科威特Arabic - Kuwait
ar_LBar_LB 阿拉伯语 - 黎巴嫩Arabic - Lebanon
ar_LYar_LY 阿拉伯语 - 利比亚Arabic - Libya
ar_MA 阿拉伯语 - 摩洛哥Arabic - Morocco
ar_OMar_OM 阿拉伯语 - 阿曼Arabic - Oman
ar_QAar_QA 阿拉伯语 - 卡塔尔Arabic - Qatar
ar_SAar_SA 阿拉伯语 - 沙特阿拉伯Arabic - Saudi Arabia
ar_SD 阿拉伯语 - 苏丹Arabic - Sudan
ar_SY 阿拉伯语 - 叙利亚Arabic - Syria
ar_TNar_TN 阿拉伯语 - 突尼斯Arabic - Tunisia
ar_YE 阿拉伯语 - 也门Arabic - Yemen
be_BYbe_BY 白俄罗斯语 - 白俄罗斯Belarusian - Belarus
bg_BG 保加利亚语 - 保加利亚Bulgarian - Bulgaria
ca_ES 加泰罗尼亚语 - 西班牙Catalan - Spain
cs_CZ 捷克 - 捷克共和国Czech - Czech Republic
da_DK 丹麦语 - 丹麦Danish - Denmark
de_ATde_AT 德语 - 奥地利German - Austria
de_BEde_BE 德国 - 比利时German - Belgium
de_CH 德语 - 瑞士German - Switzerland
de_DEde_DE 德语 - 德国German - Germany
de_LUde_LU 德语 - 卢森堡German - Luxembourg
el_GR 希腊语 - 希腊Greek - Greece
en_AUen_AU 英语 - 澳大利亚English - Australia
en_CA 英语 - 加拿大English - Canada
en_GB 英语 - 英国English - United Kingdom
en_IN 英语 - 印度English - India
en_NZen_NZ 英语 - 新西兰English - New Zealand
en_PH 英语 - 菲律宾English - Philippines
en_US 英语 - 美国English - United States
en_ZAen_ZA 英语 - 南非English - South Africa
en_ZW 英语 - 津巴布韦English - Zimbabwe
es_AR 西班牙语 - 阿根廷Spanish - Argentina
es_BO 西班牙语 - 玻利维亚Spanish - Bolivia
es_CLes_CL 西班牙语 - 智利Spanish - Chile
es_COes_CO 西班牙语 - 哥伦比亚Spanish - Colombia
es_CR 西班牙语 - 哥斯达黎加Spanish - Costa Rica
es_DOes_DO 西班牙语 - 多米尼加共和国Spanish - Dominican Republic
es_EC 西班牙语 - 厄瓜多尔Spanish - Ecuador
es_ES 西班牙语 - 西班牙Spanish - Spain
es_GTes_GT 西班牙语 - 危地马拉Spanish - Guatemala
es_HN 西班牙语 - 洪都拉斯Spanish - Honduras
es_MX 西班牙语 - 墨西哥Spanish - Mexico
es_NIes_NI 西班牙语 - 尼加拉瓜Spanish - Nicaragua
es_PAes_PA 西班牙语 - 巴拿马Spanish - Panama
es_PE 西班牙语 - 秘鲁Spanish - Peru
es_PR 西班牙语 - 波多黎各Spanish - Puerto Rico
es_PY 西班牙语 - 巴拉圭Spanish - Paraguay
es_SV 西班牙语 - 萨尔瓦多Spanish - El Salvador
es_US 西班牙语 - 美国Spanish - United States
es_UYes_UY 西班牙语 - 乌拉圭Spanish - Uruguay
es_VE 西班牙语 - 委内瑞拉Spanish - Venezuela
et_EE 爱沙尼亚语 - 爱沙尼亚Estonian - Estonia
eu_ES 巴斯克 - 西班牙Basque - Spain
fi_FI 芬兰语 - 芬兰Finnish - Finland
fo_FO 法罗语 - 法罗群岛Faroese - Faroe Islands
fr_BEfr_BE 法语 - 比利时French - Belgium
fr_CA 法语 - 加拿大French - Canada
fr_CHfr_CH 法语 - 瑞士French - Switzerland
fr_FR 法语 - 法国French - France
fr_LUfr_LU 法语 - 卢森堡French - Luxembourg
gl_ES 加利西亚语 - 西班牙Galician - Spain
gu_IN 古吉拉特语 - 印度Gujarati - India
he_IL 希伯来语 - 以色列Hebrew - Israel
hi_INhi_IN 印地语 - 印度Hindi - India
hr_HR 克罗地亚语 - 克罗地亚Croatian - Croatia
hu_HU 匈牙利语 - 匈牙利Hungarian - Hungary
id_ID 印尼语 - 印度尼西亚Indonesian - Indonesia
is_ISis_IS 冰岛语 - 冰岛Icelandic - Iceland
it_CH 意大利语 - 瑞士Italian - Switzerland
it_ITit_IT 意大利语 - 意大利Italian - Italy
ja_JP 日语 - 日本Japanese - Japan
ko_KR 韩国 - 大韩民国Korean - Republic of Korea
lt_LT 立陶宛语 - 立陶宛Lithuanian - Lithuania
lv_LVlv_LV 拉脱维亚语 - 拉脱维亚Latvian - Latvia
mk_MK 马其顿语 - 北马其顿Macedonian - North Macedonia
mn_MN 蒙古 - 蒙古语Mongolia - Mongolian
ms_MYms_MY 马来语 - 马来西亚Malay - Malaysia
nb_NO 挪威语(书面语)- 挪威Norwegian(Bokmål) - Norway
nl_BE 荷兰语 - 比利时Dutch - Belgium
nl_NLnl_NL 荷兰语 - 荷兰Dutch - The Netherlands
no_NOno_NO 挪威语 - 挪威Norwegian - Norway
pl_PL 波兰语 - 波兰Polish - Poland
pt_BRpt_BR 葡萄牙语 - 巴西Portugese - Brazil
pt_PTpt_PT 葡萄牙语 - 葡萄牙Portugese - Portugal
rm_CH 罗曼什语 - 瑞士Romansh - Switzerland
ro_RO 罗马尼亚语 - 罗马尼亚Romanian - Romania
ru_RU 俄语 - 俄罗斯Russian - Russia
ru_UA 俄罗斯 - 乌克兰Russian - Ukraine
sk_SK 斯洛伐克语 - 斯洛伐克Slovak - Slovakia
sl_SIsl_SI 斯洛文尼亚语 - 斯洛文尼亚Slovenian - Slovenia
sq_AL 阿尔巴尼亚语 - 阿尔巴尼亚Albanian - Albania
sr_RS 塞尔维亚语 - 塞尔维亚Serbian - Serbia
sv_FI 瑞典语 - 芬兰Swedish - Finland
sv_SE 瑞典语 - 瑞典Swedish - Sweden
ta_INta_IN 泰米尔语 - 印度Tamil - India
te_INte_IN 泰卢固语 - 印度Telugu - India
th_THth_TH 泰国 - 泰国Thai - Thailand
tr_TR 土耳其语 - 土耳其Turkish - Turkey
uk_UAuk_UA 乌克兰语 - 乌克兰Ukrainian - Ukraine
ur_PK 乌尔都语 - 巴基斯坦Urdu - Pakistan
vi_VN 越南语 - 越南Vietnamese - Vietnam
zh_CN 中文 - 中国Chinese - China
zh_HK 中文 - 香港Chinese - Hong Kong
zh_TW 中文 - 台湾Chinese - Taiwan