Lindorm SQL allows you to specify session variables for each session to manage the session status. The status change takes effect only for the current session and does not affect other sessions.
Applicable engines and versions
The syntax is applicable to all versions of LindormTable and LindormTSDB.
The version of Lindorm SQL must be 2.8.4.0 or later. For more information about how to view the version of Lindorm SQL, see SQL versions.
Syntax
Specify session variables
set_variable_statement ::= SET [SESSION] variable_identifier '=' literal
Query session variables
query_variable_statement ::= SELECT @@variable_identifier
Usage notes
Variable identifiers
The lexical rules for variable names are the same as the lexical rules for common identifiers. A variable name is an identifier that is used to represent a variable. For more information about identifiers, see Lexical structure of Lindorm SQL.
Session-level parameters
The session-level parameters specified by the
SET
statement take precedence over the global system parameters specified by theALTER SYSTEM
statement. If a session-level parameter and a global parameter are in conflict, the session-level parameter value specified by theSET
statement prevails.Modifying session-level parameters can affect the behavior of the SQL engine during the session. We recommend that you fully understand the parameters before you modify the parameters. The following table describes the parameters.
Parameter | Data type | Applicable engine | Description |
TIME_ZONE Important You can specify this parameter only for the MySQL protocol. For more information, see Use the MySQL protocol to develop applications (recommended). | String | LindormTable | Specifies the time zone of the current session. By default, the time zone is set to UTC+8. |
SQL_MODE Important The version of Lindorm SQL must be 2.8.4.8 or later. | String |
| Specifies the parsing modes of the SQL engine. If you specify multiple parsing modes, separate the parsing modes with a comma ( You can set this parameter only to |
Examples
Change the time zone of the current session
Before you modify the time zone, execute the following statement to view the time zone of the current session:
SELECT @@TIME_ZONE;
Sample result:
+-------------+ | @@TIME_ZONE | +-------------+ | +08:00 | +-------------+
Change the time zone of the current session to
UTC
.SET TIME_ZONE='UTC';
Execute the
SELECT @@TIME_ZONE;
statement to check whether the change takes effect. Sample result:+-------------+ | @@TIME_ZONE | +-------------+ | UTC | +-------------+
NoteFor more information about the relationship between the session time zone and the timestamp data, see Specify a time zone for a LindormTable connection
Specify the parsing modes of the SQL engine
Query a string constant expression.
SELECT '{\"key\":\"va\\lu\'e\r\n\"}';
Sample result:
+---------------------+ | EXPR$0 | +---------------------+ | {"key":"va\lu'e "} | +---------------------+
Specify the parsing modes of the SQL engine. When you parse string constants, do not use backslashes (
\
) as escape characters.SET SQL_MODE='NO_BACKSLASH_ESCAPES';
Execute the
SELECT '{\"key\":\"va\\lu\'e\r\n\"}';
statement to check whether the change takes effect. Sample result:+-----------------------------+ | EXPR$0 | +-----------------------------+ | {\"key\":\"va\\lu\'e\r\n\"} | +-----------------------------+