Note
This variable is available starting with V4.2.2.
Description
lc_time_names specifies the language for displaying the names and abbreviations of dates and months.
Applicability
This variable applies only to OceanBase Database in MySQL mode.
Privilege requirements
Query variables
Global level
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
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
systenant can directly modify the value of a global system variable.MySQL user tenants must have the
SUPERorALTER SYSTEMprivilege to modify the value of a global system variable.
Session level
systenant and all user tenants can directly 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 specifies the language and format of the names of months and weeks in the output string of this function. Inen_USmode, the names of months and weeks are based on English naming conventions. Inzh_CNmode, the names of months and weeks are based on Chinese naming conventions.DAYNAME()functionThe
lc_time_namesvariable specifies the language and format of the name of the week returned by this function. Inen_USmode, the name of the week is in English. Inzh_CNmode, the name of the week is in Chinese.MONTHNAME()functionThe
lc_time_namesvariable specifies the language and format of the name of the month returned by this function. Inen_USmode, the name of the month is in English. Inzh_CNmode, the name of the month is in Chinese.
Examples
The following example shows how to display the result of a date function in Chinese:
Set the language for displaying the names and abbreviations of dates and months to Chinese.
Session level
obclient> SET lc_time_names='zh_CN';Global level
obclient> SET GLOBAL lc_time_names='zh_CN';
View the current value of
lc_time_names.obclient> show variables like "lc_time_names";The return result is as follows:
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | lc_time_names | zh_CN | +---------------+-------+ 1 row in set (0.015 sec)Query the corresponding date by using a function.
Query the date in the specified format by using the
DATE_FORMAT()function.obclient> select DATE_FORMAT('2023-01-06','%Y-%m-%d');The return result is as follows:
+--------------------------------------+ | DATE_FORMAT('2023-01-06','%Y-%m-%d') | +--------------------------------------+ | 2023-01-06 | +--------------------------------------+ 1 row in set (0.001 sec)Query the name of the week corresponding to the input date by using the
DAYNAME()function.obclient> select DAYNAME('2023-01-06');The return result is as follows:
+-----------------------+ | DAYNAME('2023-01-06') | +-----------------------+ | Friday | +-----------------------+ 1 row in set (0.000 sec)Query the name of the month corresponding to the input date by using the
MONTHNAME()function.obclient> select MONTHNAME('2023-01-06');The return result is as follows:
+-------------------------+ | MONTHNAME('2023-01-06') | +-------------------------+ | January | +-------------------------+ 1 row in set (0.001 sec)