Note
This variable is available starting with V4.2.2.
Description
lc_time_names specifies the language for displaying the names and abbreviations of months and days.
Applicability
This variable is applicable only to OceanBase Database in MySQL mode.
Privilege requirements
Query variables
Global level
The
systenant and all user tenants can execute theSHOW VARIABLESstatement or query theinformation_schema.GLOBAL_VARIABLESview (MySQL mode) to view the value of a global system variable.Session level
The
systenant and all user tenants can execute theSHOW VARIABLESstatement or query theinformation_schema.SESSION_VARIABLESview (MySQL mode) to view the value of a session system variable.
Modify variables
Global level
The
systenant can modify the value of a global system variable.A MySQL user tenant must have the
SUPERorALTER SYSTEMprivilege to modify the value of a global system variable.
Session level
The
systenant and all user tenants can modify the value of a session system variable.
Attributes
| Attribute | Description |
|---|---|
| Type | Varchar |
| Default value | en_US |
| Value range |
|
| Scope |
|
| Modifiable | Yes. You can execute the SET statement to modify the value. |
Usage
This variable affects the output of the DATE_FORMAT(), DAYNAME(), and MONTHNAME() functions, but does not affect the results of the STR_TO_DATE() or GET_FORMAT() functions.
DATE_FORMAT()functionThe
lc_time_namesvariable affects the language and format of the month and day names in the output string of this function. Inen_USmode, the month and day names are based on English naming conventions. Inzh_CNmode, the names are based on Chinese naming conventions.DAYNAME()functionThe
lc_time_namesvariable affects the language and format of the day name returned by this function. Inen_USmode, the day name is in English. Inzh_CNmode, the day name is in Chinese.MONTHNAME()functionThe
lc_time_namesvariable affects the language and format of the month name returned by this function. Inen_USmode, the month name is in English. Inzh_CNmode, the month name is in Chinese.
Examples
Assume that you want to display the result of a date function in Chinese.
Set the language for displaying the names and abbreviations of months and days to Chinese.
Session level
obclient> SET lc_time_names='zh_CN';Global level
obclient> SET GLOBAL lc_time_names='zh_CN';
View the value of
lc_time_names.obclient> show variables like "lc_time_names";The returned result is as follows:
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | lc_time_names | zh_CN | +---------------+-------+ 1 row in set (0.015 sec)Query the corresponding date using a function.
Use the
DATE_FORMAT()function to query the date in the specified format.obclient> select DATE_FORMAT('2023-01-06','%Y-%m-%d');The returned result is as follows:
+--------------------------------------+ | DATE_FORMAT('2023-01-06','%Y-%m-%d') | +--------------------------------------+ | 2023-01-06 | +--------------------------------------+ 1 row in set (0.001 sec)Use the
DAYNAME()function to query the name of the day of the week corresponding to the input date.obclient> select DAYNAME('2023-01-06');The returned result is as follows:
+-----------------------+ | DAYNAME('2023-01-06') | +-----------------------+ | Friday | +-----------------------+ 1 row in set (0.000 sec)Use the
MONTHNAME()function to query the name of the month corresponding to the input date.obclient> select MONTHNAME('2023-01-06');The returned result is as follows:
+-------------------------+ | MONTHNAME('2023-01-06') | +-------------------------+ | January | +-------------------------+ 1 row in set (0.001 sec)