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 obtain the value of the auto-increment column of the last inserted row.
Privilege requirements
Query variables
Global level
systenant and all user tenants can execute theSHOW VARIABLESstatement or query theSYS.TENANT_VIRTUAL_GLOBAL_VARIABLEview (Oracle mode) or theinformation_schema.GLOBAL_VARIABLESview (MySQL mode) to obtain the value of a global system variable.Session level
systenant and all user tenants can execute theSHOW VARIABLESstatement or query theSYS.TENANT_VIRTUAL_SESSION_VARIABLEview (Oracle mode) or theinformation_schema.SESSION_VARIABLESview (MySQL mode) to obtain the value of a session system variable.
Modify variables
Global level
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
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 is created with the following statement:
obclient> CREATE TABLE t1 (auto_inc_column auto_increment, j int);
If the value of sql_auto_is_null is 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 allow you to obtain 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;