Sets a runtime parameter for the current session. ALTER SESSION only changes the value that is used by the current session.
Syntax
ALTER SESSION SET name = valueParameters
| Parameter | Description |
|---|---|
name | The name of the runtime parameter to set. |
value | The new value for the parameter. |
Supported parameters
PolarDB for PostgreSQL (Compatible with Oracle) supports the following ALTER SESSION parameters. Parameters fall into two categories: those that change runtime behavior, and those accepted for Oracle syntax compatibility but have no effect.
Parameters that take effect
| Parameter | Type | Valid values | Default | Description |
|---|---|---|---|---|
NLS_DATE_FORMAT | string | — | — | Sets the date format for displaying date and time values and for interpreting ambiguous data input values. Has the same effect as the PostgreSQL datestyle parameter. |
NLS_LANGUAGE | string | — | — | Sets the language for system messages. Has the same effect as the PostgreSQL lc_messages parameter. The value must use the PostgreSQL locale format (for example, en_US.UTF-8), not the Oracle language name format. |
OPTIMIZER_MODE | string | ALL_ROWS, CHOOSE, FIRST_ROWS, FIRST_ROWS_10, FIRST_ROWS_100, FIRST_ROWS_1000 | CHOOSE | Sets the default query optimizer mode. |
Syntax-compatibility parameters (no effect)
The following parameters are accepted to maintain Oracle syntax compatibility but do not change runtime behavior in PolarDB for PostgreSQL (Compatible with Oracle).
| Parameter | Type | Valid values | Default |
|---|---|---|---|
NLS_LENGTH_SEMANTICS | string | BYTE, CHAR | BYTE |
QUERY_REWRITE_ENABLED | string | TRUE, FALSE, FORCE | FALSE |
QUERY_REWRITE_INTEGRITY | string | ENFORCED, TRUSTED, STALE_TOLERATED | ENFORCED |
Examples
Set the session language to English (United States) with UTF-8 encoding:
ALTER SESSION SET NLS_LANGUAGE = 'en_US.UTF-8';The locale value en_US.UTF-8 uses the PostgreSQL format, not the Oracle language name format. This format is not compatible with Oracle databases.Set the date display format to day/month/year:
ALTER SESSION SET NLS_DATE_FORMAT = 'dd/mm/yyyy';该文章对您有帮助吗?