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"
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: The ISO format is recommended.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
IntervalStyle
Parameter description: Specifies the display format for interval values.
Value type: enumerated type.
Unit: none
Value range:
- sql_standard: Output matching SQL standards will be generated.
- postgres: Output matching PostgreSQL 8.4 will be generated. It is valid when the DateStyle parameter is set to ISO.
- postgres_verbose: Output matching PostgreSQL 8.4 will be generated. It is valid when the DateStyle parameter is set to non_ISO.
- iso_8601: Output matching the time interval "format with designators" defined in ISO 8601 will be generated.
- a: Output that matches the numtodsinterval function will be generated. 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
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
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 range. For details, see "System Catalogs and System Views > System Views > Other System Views > PG_TIMEZONE_NAMES" in Developer Guide.
Default value: "PRC"

- gs_initdb will set a time zone value that is consistent with the system environment.
- When sql_compatibility is set to M and m_format_dev_version is set to 's2', the value range is the same as that of time_zone.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
timezone_abbreviations
Parameter description: Specifies the time zone abbreviations that will be accepted by the server. This parameter can be set at the PDB level.
Parameter type: string.
Unit: none
Value range: "India", "Australia", and "Default".
Default value: "Default" In the PDB scenario, if this parameter is not set, the global setting is inherited.

"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.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
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, according to the actual situation). This parameter can be set at the PDB level.
Parameter type: integer.
Unit: none
Value range: –15 to 3

- If the value is greater than 0, some key data bits are included, but the included data bits may not be valid. As a result, the output digits may not be completely valid. It is especially useful for dumping float data that needs to be restored exactly.
- If the value is less than or equal to 0, unnecessary data bits are eliminated to ensure that the output digits are valid.
- In M-compatible mode, extra_float_digits affects only the number of data bits displayed for the float4 data type without scale. The number of data bits displayed for the float8 data type and the float4 data type with scale is not affected by the GUC parameter.
Default value: 0. In the PDB scenario, if this parameter is not set, the global setting is inherited.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
float_shortest_precision
Parameter description: Specifies whether to enable the minimum precision method to replace sprintf() to serialize floating point numbers. The minimum precision method is used to improve performance of a floating-point number serialization system function, that is, shorten execution time of a single thread of two system functions float4out() and float8out(). In the multi-tenancy scenario, this parameter can be set at the PDB level.
Parameter type: Boolean.
Unit: none
Value range: Boolean
- on: The minimum precision method is enabled.
- off: The minimum precision method is disabled.
Default value: off. In the PDB scenario, if this parameter is not set, the global setting is inherited.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1 GUC parameters.
Setting suggestion: You are advised to set this parameter for new sites or sites that have performance requirements for floating-point serialization.
Risks and impacts of improper settings: After this parameter is enabled, the precision of valid float digits varies according to the value of extra_float_digits. The value range of extra_float_digits is –15 to 3, the number of valid digits required for each value is as follows.
Value of extra_float_digits |
Number of Required Valid Digits |
|
Float4 |
Float8 |
|
-15 |
1 |
1 |
-14 |
1 |
1 |
-13 |
1 |
2 |
-12 |
1 |
3 |
-11 |
1 |
4 |
-10 |
1 |
5 |
-9 |
1 |
6 |
-8 |
1 |
7 |
-7 |
1 |
8 |
-6 |
1 |
9 |
-5 |
1 |
10 |
-4 |
2 |
11 |
-3 |
3 |
12 |
-2 |
4 |
13 |
-1 |
5 |
14 |
0 |
6 |
15 |
1 |
7 |
16 |
2 |
8 |
17 |
3 |
9 |
18 |

- For the original logic that calls snprintf_s(), the number of required valid digits does not mean that all output digits are valid.
- When the value of extra_float_digits is greater than 0, the output digits are not guaranteed to be completely valid.
- When the value of extra_float_digits is less than or equal to 0, the output digits are completely valid.
- For the new logic that uses the minimum precision method, only valid digits are output.
- When the value of extra_float_digits is greater than 0, it is not guaranteed that the number of output digits reaches the number of required valid digits, but all output digits are valid.
- When the value of extra_float_digits is less than or equal to 0, the output digits are completely valid.
client_encoding
Parameter description: Specifies the client-side encoding (character set). This parameter can be set at the PDB level.
Parameter type: string.
Unit: none
Value range: encoding types 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". In the PDB scenario, if this parameter is not set, the global setting is inherited.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Set this parameter based on frontend services. Try to keep the encoding consistent on the client and server to improve efficiency. You are advised to set this parameter to "SQL_ASCII" or "UTF8".
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
lc_messages
Parameter description: Specifies the language in which messages are displayed. This parameter can be set at the PDB level.
Parameter type: string.
Unit: none
Value range: The value range is related to the system. You can run the locale -a command to view the value range.

- You can run the locale -a command to check the system-supported locales and the corresponding encodings, and select one as required.
- On some systems, this value range 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.
- 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". In the PDB scenario, if this parameter is not set, the global setting is inherited.
Setting method: This is a SUSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
lc_monetary
Parameter description: Specifies the display format of monetary values. It affects the output of functions such as to_char(). This parameter can be set at the PDB level.
Parameter type: string.
Unit: none
Value range: The value range is related to the system. You can run the locale -a command to view the value range.

- 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". In the PDB scenario, if this parameter is not set, the global setting is inherited.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
lc_numeric
Parameter description: Specifies the display format of numbers. It affects the output of functions such as to_char. This parameter can be set at the PDB level.
Parameter type: string.
Unit: none
Value range: The value range is related to the system. You can run the locale -a command to view the value range.

- 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". In the PDB scenario, if this parameter is not set, the global setting is inherited.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
lc_time
Parameter description: Specifies the display format of time and locale. It affects the output of functions such as to_char(). This parameter can be set at the PDB level.
Parameter type: string.
Unit: none
Value range: The value range is related to the system. You can run the locale -a command to view the value range.

- 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". In the PDB scenario, if this parameter is not set, the global setting is inherited.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
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. This parameter can be set at the PDB level.
Parameter type: string.
Unit: none
Value range: IETF language tags in simple format, such as en_US or zh_CN.
Default value: "en_US". In the PDB scenario, if this parameter is not set, the global setting is inherited.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Switch the language based on service requirements.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
default_week_format
Parameter description: Specifies the default mode value of the week() function. The following table lists the value range and description. This parameter can be set at the PDB level.
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: –2147483648 to 2147483647
- If the value is less than 0, it is forcibly changed to 0.
- If the value is greater than 7, it is forcibly changed to 7.
Default value: 0. In the PDB scenario, if this parameter is not set, the global setting is inherited.
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Select a mode based on service requirements.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
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