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
systenants and all user tenants can execute theSHOW VARIABLESstatement or query theSYS.TENANT_VIRTUAL_GLOBAL_VARIABLEview (Oracle-compatible mode) or theinformation_schema.GLOBAL_VARIABLESview (MySQL-compatible mode) to obtain the value of Global system variables.Session level
systenants and all user tenants can execute theSHOW VARIABLESstatement or query theSYS.TENANT_VIRTUAL_SESSION_VARIABLEview (Oracle-compatible mode) or theinformation_schema.SESSION_VARIABLESview (MySQL-compatible mode) to obtain the value of Session system variables.
Modify variables
Global level
systenants can directly modify the value of Global system variables.MySQL user tenants must have the
SUPERorALTER SYSTEMprivilege to modify the value of Global system variables.Oracle user tenants must have the
ALTER SYSTEMprivilege to modify the value of Global system variables.
Session level
systenants and all user tenants can directly modify the value of Session system variables.
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 by using the following statement:
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
Enable direct query 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;