Session variables let you control SQL engine behavior on a per-connection basis. Changes take effect immediately for the current session and do not affect other sessions.
Prerequisites
Before you begin, ensure that you have:
Lindorm SQL version 2.8.4.0 or later. To check your version, see SQL versions.
Applicable engines
LindormTable and LindormTSDB (all versions).
Syntax
Set a session variable:
SET [SESSION] variable_identifier = literalQuery a session variable:
SELECT @@variable_identifierVariable names follow the same lexical rules as common identifiers. For details, see Lexical structure of Lindorm SQL.
Session variables reference
Session-level parameters set by SET take precedence over global parameters set by ALTER SYSTEM. When the two conflict, the session-level value always wins.
Modifying session-level parameters affects SQL engine behavior for the duration of the session. Understand each parameter before changing it.
TIME_ZONE
| Attribute | Value |
|---|---|
| Data type | String |
| Default | +08:00 (UTC+8) |
| Applicable engine | LindormTable |
| Protocol constraint | MySQL protocol only |
Sets the time zone for the current session. Only available when connecting via the MySQL protocol.
SQL_MODE
| Attribute | Value |
|---|---|
| Data type | String |
| Applicable engine | LindormTable, LindormTSDB |
| Introduced in | Lindorm SQL 2.8.4.8 |
Controls the SQL engine parsing behavior. To set multiple modes, separate them with a comma (,).
Only supported value:
NO_BACKSLASH_ESCAPES— Backslashes (\) are treated as literal characters rather than escape characters when parsing string literals.
Examples
Change the session time zone
Query the current session time zone:
SELECT @@TIME_ZONE;Expected output:
+-------------+ | @@TIME_ZONE | +-------------+ | +08:00 | +-------------+Change the time zone to UTC:
SET TIME_ZONE='UTC';Verify the change:
SELECT @@TIME_ZONE;Expected output:
+-------------+ | @@TIME_ZONE | +-------------+ | UTC | +-------------+
For details on how the session time zone affects timestamp data, see Specify a time zone for a LindormTable connection.
Disable backslash escaping
Query a string literal to observe the default escape behavior:
SELECT '{\"key\":\"va\\lu\'e\r\n\"}';Expected output:
+---------------------+ | EXPR$0 | +---------------------+ | {"key":"va\lu'e "} | +---------------------+Set
NO_BACKSLASH_ESCAPESto disable backslash escaping:SET SQL_MODE='NO_BACKSLASH_ESCAPES';Run the same query to verify the change:
SELECT '{\"key\":\"va\\lu\'e\r\n\"}';Expected output:
+-----------------------------+ | EXPR$0 | +-----------------------------+ | {\"key\":\"va\\lu\'e\r\n\"} | +-----------------------------+With
NO_BACKSLASH_ESCAPESactive, backslashes are no longer treated as escape characters, so the string is returned as-is.