Note
This variable is available starting with V2.2.77.
Description
sql_auto_is_null is used by some special drivers, such as ODBC, to control whether to retrieve the value of the auto-increment column of the last inserted row.
Privilege requirements
Query variables
Global level
The
systenant and all user tenants can use theSHOW VARIABLESstatement or theSYS.TENANT_VIRTUAL_GLOBAL_VARIABLEview (Oracle mode) and theinformation_schema.GLOBAL_VARIABLESview (MySQL mode) to view the value of a global system variable.Session level
The
systenant and all user tenants can use theSHOW VARIABLESstatement or theSYS.TENANT_VIRTUAL_SESSION_VARIABLEview (Oracle mode) and theinformation_schema.SESSION_VARIABLESview (MySQL mode) to view the value of a session system variable.
Modify variables
Global level
The
systenant can directly modify the value of a global system variable.MySQL user tenants must have the
SUPERorALTER SYSTEMprivilege to modify the value of a global system variable.Oracle user tenants must have the
ALTER SYSTEMprivilege to modify the value of a global system variable.
Session level
The
systenant and all user tenants can directly modify the value of a session system variable.
Attributes
| Attribute | Description |
|---|---|
| Type | Bool |
| Default value | OFF |
| Value range | |
| Scope |
|
| Modifiable | Yes. You can execute the SET statement to modify the value. |
Usage
Assume that a table named t1 exists. The statement for creating the table is as follows:
obclient> CREATE TABLE t1 (auto_inc_column auto_increment, j int);
When sql_auto_is_null is set to ON, the following two statements are equivalent:
obclient> SELECT * FROM t1 WHERE auto_inc_column is null;
obclient> SELECT * FROM t1 WHERE auto_inc_column = last_insert_id();
Examples
Set the value of sql_auto_is_null to ON so that you can directly query the value of the auto-increment column of the last inserted row by using the IS NULL condition.
Session level
obclient> SET sql_auto_is_null = on;Global level
obclient> SET GLOBAL sql_auto_is_null = on;