Locale and Formatting
This section describes parameters related to the time format setting.
DateStyle
Parameter description: Specifies the display format for date and time values, as well as the rules for interpreting ambiguous date input values.
This variable contains two independent components: the output format declaration (ISO, Postgres, SQL, or German) and the input/output order of year/month/day (DMY, MDY, YMD, Euro, European, US, NonEuro, NonEuropean, or Default). The two components can be set separately or together. The keywords Euro and European are synonyms for DMY. The keywords US, NonEuro, and NonEuropean are synonyms for MDY.
Parameter type: string
Unit: none
Value range: combination of the output format declaration and the input/output order of year/month/day. (The two components can be set separately.)
- Output format declaration: ISO, Postgres, SQL, or German
- Input/Output order of year/month/day: DMY (Euro, European), MDY (US, NonEuro, NonEuropean), or YMD
Default value: "ISO, MDY"
gs_initdb will initialize this parameter so that its value is the same as that of lc_time.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: The ISO format is recommended.
IntervalStyle
Parameter description: Specifies the display format for interval values.
This is a USERSET parameter. Set it based on instructions provided in Table 1.
Value range: enumerated values
- sql_standard indicates that output matching SQL standards will be generated.
- postgres indicates that output matching PostgreSQL 8.4 will be generated when the DateStyle parameter is set to ISO.
- postgres_verbose indicates that output matching PostgreSQL 8.4 will be generated when the DateStyle parameter is set to non_ISO.
- iso_8601 indicates that output matching the time interval "format with designators" defined in ISO 8601 will be generated.
- a indicates the output that matches the numtodsinterval function. For details, see "SQL Reference > Functions and Operators > Date and Time Processing Functions and Operators > numtodsinterval" in Developer Guide.
The IntervalStyle parameter also affects the interpretation of ambiguous interval input.
Default value: postgres
TimeZone
Parameter description: Specifies the time zone for displaying and interpreting timestamps.
Parameter type: string
Unit: none
Value range: You can query the PG_TIMEZONE_NAMES view to obtain the value. For details, see "System Catalogs and System Views > System Views > PG_TIMEZONE_NAMES" in Developer Guide.
Default value: "PRC"
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
gs_initdb will set a time zone value that is consistent with the system environment.
timezone_abbreviations
Parameter description: Specifies the time zone abbreviations that will be accepted by the server.
This is a USERSET parameter. Set it based on instructions provided in Table 1.
Value range: a string. India, Australia, or Default.
Default value: Default
Default indicates an abbreviation that works in most of the world, which is applicable to most cases. There are also other abbreviations, such as 'Australia' and 'India' that can be defined for a particular installation. For other time zone abbreviations, you need to set them in the corresponding configuration files before creating the database.
extra_float_digits
Parameter description: Adjusts the number of digits displayed for floating-point values, including float4, float8, and geometric data types. The parameter value is added to the standard number of digits (FLT_DIG or DBL_DIG as appropriate).
This is a USERSET parameter. Set it based on instructions provided in Table 1.
Value range: an integer ranging from –15 to 3.
- This parameter can be set to 3 to include partially-significant digits. It is especially useful for dumping float data that needs to be restored exactly.
- This parameter can also be set to a negative value to suppress unwanted digits.
Default value: 0
client_encoding
Parameter description: Specifies the client-side encoding (character set).
Set this parameter based on the situation of the front-end services. Try to keep the encoding consistent on the client and server to improve efficiency.
This is a USERSET parameter. Set it based on instructions provided in Table 1.
Value range: encoding compatible with PostgreSQL. UTF8 indicates that the database encoding is used.
- You can run the locale -a command to check the system-supported locales and the corresponding encodings, and select one as required. The sorting rules may vary according to OSs or versions of the same OS. When application services are logically migrated between these OSs, differences and changes in OS sorting rules may cause differences in database functions such as indexes, partitions, and sorting operators. For example, data result sets returned by a same range query statement are different, or query results returned by a same sorting query statement are different. The application service needs to check whether the service data contains related characters based on the locale differences released by the OS.
- By default, gs_initdb will initialize the setting of this parameter based on the current system environment. You can also run the locale command to check the current configuration environment.
- To use consistent encoding for communication within the database, you are advised to retain the default value of client_encoding. Modification to this parameter in the gaussdb.conf file (by using the gs_guc tool, for example) does not take effect.
- client_encoding can be set to GB18030_2022. When client_encoding is set to gb18030_2022, ensure that the GB18030 character set supported by the client OS has been upgraded to version 2022.
- If the encoding format of the database character set is UTF8, the encoding format of the region supported by the current system is GB18030, the GB18030 character set supported by the client OS has been upgraded to version 2022, and the database contains historical data stored before the GB18030 character set is upgraded, the following situations may occur:
- When client_encoding is set to gb18030, the character encoding of historical data in the UTF8 database returned to the client is the same as that before the client character set is upgraded. However, the font of 38 characters whose mapping changes during the character set upgrade is the same as that in version 2022.
- When client_encoding is set to gb18030_2022, the character encoding of historical data in the UTF8 database returned to the client are the same as that after the upgrade of the client character set and the font of characters are the same as that before the upgrade. This is because the versions of the GB18030 character set are not completely compatible, which may cause data inconsistency. Therefore, if the GB18030 character set needs to be upgraded on the client and historical data exists, you need to convert the historical data before the upgrade.
- client_encoding can be set to ZHS16GBK. The following table lists the setting methods of server_encoding and client_encoding corresponding to all ways that ZHS16GBK, GB18030, and GB18030_2022 character sets can be transformed.
server_encoding |
client_encoding |
locale |
Setting Method |
zhs16gbk |
utf8 |
utf8 |
The database automatically obtains the value of locale. |
utf8 |
zhs16gbk |
gbk |
|
zhs16gbk |
zhs16gbk |
gbk |
|
zhs16gbk |
gb18030 |
gb18030 |
|
gb18030 |
zhs16gbk |
gbk |
|
zhs16gbk |
gb18030-2022 |
gb18030 |
|
gb18030-2022 |
zhs16gbk |
gbk |
|
gb18030 |
utf8 |
utf8 |
The database automatically obtains the value of locale. |
utf8 |
gb18030 |
gb18030 |
|
gb18030_2022 |
utf8 |
utf8 |
The database automatically obtains the value of locale. |
utf8 |
gb18030_2022 |
gb18030 |
|
gb18030 |
gb18030 |
gb18030 |
|
gb18030_2022 |
gb18030_2022 |
gb18030 |
|
Default value: UTF8
Recommended value: SQL_ASCII or UTF8
lc_messages
Parameter description: Specifies the language in which messages are displayed.
- Acceptable values are system-related.
- On some systems, this locale category does not exist. Setting this variable will still work, but there will be no effect. In addition, translated messages for the desired language may not exist. In this case, you can still see the English messages.
This is a SUSET parameter. Set it based on instructions provided in Table 1.
Value range: a string
- You can run the locale -a command to check the system-supported locales and the corresponding encodings, and select one as required.
- By default, gs_initdb will initialize the setting of this parameter based on the current system environment. You can also run the locale command to check the current configuration environment.
Default value: C
lc_monetary
Parameter description: Specifies the display format of monetary values. It affects the output of functions such as to_char. Acceptable values are system-related.
This is a USERSET parameter. Set it based on instructions provided in Table 1.
Value range: a string
- You can run the locale -a command to check the system-supported locales and the corresponding encodings, and select one as required.
- By default, gs_initdb will initialize the setting of this parameter based on the current system environment. You can also run the locale command to check the current configuration environment.
Default value: C
lc_numeric
Parameter description: Specifies the display format of numbers. It affects the output of functions such as to_char. Acceptable values are system-related.
This is a USERSET parameter. Set it based on instructions provided in Table 1.
Value range: a string
- You can run the locale -a command to check the system-supported locales and the corresponding encodings, and select one as required.
- By default, gs_initdb will initialize the setting of this parameter based on the current system environment. You can also run the locale command to check the current configuration environment.
Default value: C
lc_time
Parameter description: Specifies the display format of time and locale. It affects the output of functions such as to_char. Acceptable values are system-related.
This is a USERSET parameter. Set it based on instructions provided in Table 1.
Value range: a string
- You can run the locale -a command to check the system-supported locales and the corresponding encodings, and select one as required.
- By default, gs_initdb will initialize the setting of this parameter based on the current system environment. You can also run the locale command to check the current configuration environment.
Default value: C
lc_time_names
Parameter description: Specifies the language used to display names and abbreviations of dates and months. The output of the DATE_FORMAT(), DAYNAME(), and MONTHNAME() functions is affected. The performance of STR_TO_DATE() and GET_FORMAT() is not affected.
Parameter type: string
Unit: none
Value range: IETF language tags in simple format, such as en_US or zh_CN.
Default value: en_US
Setting method: This is a USERSET parameter. Set it based on instructions provided in Setting GUC Parameters.
Setting suggestion: Switch the language based on service requirements.
default_week_format
Parameter description: Specifies the default mode value of the week() function. The following table lists the value range and description.
default_week_format |
First Day of a Week |
Range |
First Week Definition |
---|---|---|---|
0 |
Sunday |
0 to 53 |
The first week that contains a Sunday in this year. |
1 |
Monday |
0 to 53 |
The first week that contains four or more days in this year. |
2 |
Sunday |
1 to 53 |
The first week that contains a Sunday in this year. |
3 |
Monday |
1 to 53 |
The first week that contains four or more days in this year. |
4 |
Sunday |
0 to 53 |
The first week that contains four or more days in this year. |
5 |
Monday |
0 to 53 |
The first week that contains a Monday in this year. |
6 |
Sunday |
1 to 53 |
The first week that contains four or more days in this year. |
7 |
Monday |
1 to 53 |
The first week that contains a Monday in this year. |
For week 1 of a year, the number 1 indicates a week number. The week number of the first week of a year may be 0, depending on the value of week_format, as shown in the third column.
Parameter type: integer
Unit: none
Value range: [0,7]
Default value: 0
Setting method: This is a USERSET parameter. Set it based on instructions provided in Setting GUC Parameters.
Setting suggestion: Select a mode based on service requirements.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot