Note
This variable was introduced in OceanBase Database V4.2.2.
Description
lc_time_names specifies the language in which date and month names and their abbreviations are displayed.
Applicability
This variable is applicable to only OceanBase Database in MySQL mode.
Limitations
Query the variable
Global-level operation
In the
systenant or a user tenant, you can execute theSHOW VARIABLESstatement to query the variable at the global level or query theinformation_schema.GLOBAL_VARIABLESview (in MySQL mode) for the variable at the global level.Session-level operation
In the
systenant or a user tenant, you can execute theSHOW VARIABLESstatement to query the variable at the session level or query theinformation_schema.SESSION_VARIABLESview (in MySQL mode) for the variable at the session level.
Modify the variable
Global-level operation
In the
systenant, you can directly change the value of the variable at the global level.In a MySQL user tenant, you must have the
SUPERorALTER SYSTEMprivilege to change the value of the variable at the global level.
Session-level operation
In the
systenant or a user tenant, you can directly change the value of the variable at the session level for the current tenant.
Attributes
| Attribute | Description |
|---|---|
| Type | Varchar |
| Default value | en_US |
| Value range | |
| Effective scope | |
| Modifiable | Yes. You can use the SET statement to modify the variable. |
Considerations
This variable affects the output of the DATE_FORMAT(), DAYNAME(), and MONTHNAME() functions, but does not affect the output of the STR_TO_DATE() or GET_FORMAT() function.
DATE_FORMAT()functionIn this function,
lc_time_namesaffects the language and format of the month and day of the week in the output string. The month and day of the week in the output string are named based on the English naming conventions inen_USmode and based on the Chinese naming conventions inzh_CNmode.DAYNAME()functionIn this function,
lc_time_namesaffects the language and format of the day of the week returned. The day of the week is returned in English inen_USmode and in Chinese inzh_CNmode.MONTHNAME()functionIn this function,
lc_time_namesaffects the language and format of the month returned. The month is returned in English inen_USmode and in Chinese inzh_CNmode.
Examples
Take the output of a date function as an example:
Set the language in which the date and month names and their abbreviations are displayed to English.
Session-level operation
obclient> SET lc_time_names='en_US';Global-level operation
obclient> SET GLOBAL lc_time_names='en_US';
Query the current value of
lc_time_names.obclient> show variables like "lc_time_names";The query result is as follows:
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | lc_time_names | en_US | +---------------+-------+ 1 row in set (0.015 sec)Use the functions to query the input date.
Use the
DATE_FORMAT()function to query the format of the input date.obclient> select DATE_FORMAT('2023-01-06','%Y-%m-%d');The query 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 day of the week of the input date.obclient> select DAYNAME('2023-01-06');The query result is as follows:
+-----------------------+ | DAYNAME('2023-01-06') | +-----------------------+ | Friday | +-----------------------+ 1 row in set (0.000 sec)Use the
MONTHNAME()function to query the month of the input date.obclient> select MONTHNAME('2023-01-06');The query result is as follows:
+-------------------------+ | MONTHNAME('2023-01-06') | +-------------------------+ | January | +-------------------------+ 1 row in set (0.001 sec)