Note
This variable is available starting with V1.4.
Description
The sql_mode variable specifies the SQL mode. Different SQL modes have significant effects on database behavior.
Note
This variable is available only in OceanBase Database in MySQL mode.
Privilege requirements
Query variables
Global level
The
systenant and all user tenants can execute theSHOW VARIABLESstatement or query theinformation_schema.GLOBAL_VARIABLESview (MySQL mode) to obtain the values of global system variables.Session level
The
systenant and all user tenants can execute theSHOW VARIABLESstatement or query theinformation_schema.SESSION_VARIABLESview (MySQL mode) to obtain the values of session system variables.
Modify variables
Global level
The
systenant can directly modify the values of global system variables.MySQL user tenants must have the
SUPERorALTER SYSTEMprivilege to modify the values of global system variables.
Session level
The
systenant and all user tenants can directly modify the values of session system variables.
Attributes
| Attribute | Description | ||
|---|---|---|---|
| Parameter type | Uint | ||
| Default value | STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER
Note
|
||
| Value range | The value can be any combination of the following values:
|
) operator as a string concatenation operator (same as CONCAT()) instead of an alias for the OR operator. PAD_CHAR_TO_FULL_LENGTH: Retains trailing spaces in CHAR columns during retrieval and fills the retrieved CHAR values to their full length.REAL_AS_FLOAT: By default, treats REAL as an alias for DOUBLE. After this value is set, REAL is treated as an alias for FLOAT.STRICT_ALL_TABLES: Enables the strict SQL mode for all storage engines and rejects invalid data values.STRICT_TRANS_TABLES: Enables the strict SQL mode for transactional storage engines and, if possible, for non-transactional storage engines.TIME_TRUNCATE_FRACTIONAL: Controls whether to round TIME, DATE, or TIMESTAMP values with fractional seconds when inserting them into columns of the same type with fewer decimal places. By default, rounding is performed. If this mode is enabled, the fractional part is discarded.ANSI: Equivalent to the combination of REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, and ONLY_FULL_GROUP_BY.DB2: Equivalent to the combination of PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, and NO_FIELD_OPTIONS.MAXDB: Equivalent to the combination of PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS, and NO_AUTO_CREATE_USER.MSSQL: Equivalent to the combination of PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, and NO_FIELD_OPTIONS.MYSQL323: Equivalent to the combination of HIGH_NOT_PRECEDENCE with some additional features specific to MySQL 3.23.MYSQL40: Equivalent to the combination of HIGH_NOT_PRECEDENCE with some additional features specific to MySQL 4.0.ORACLE: Equivalent to the combination of PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS, and NO_AUTO_CREATE_USER.POSTGRESQL: Equivalent to the combination of PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, and NO_FIELD_OPTIONS. |
|
| Scope |
|
||
| Modifiable | Yes. You can execute the SET statement to modify the value. |
||
Examples
Set the SQL mode to STRICT_ALL_TABLES, NO_ZERO_IN_DATE, and NO_AUTO_CREATE_USER.
Session level
obclient> SET sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER';Global level
obclient> SET GLOBAL sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER';