Overview
sql_auto_is_null is used by some special drivers, such as ODBC, to control whether to fetch the auto-increment column value of the last inserted row.
Privilege requirements
Query variables
Global level
The
systenant and all user tenants can use theSHOW VARIABLESstatement and theinformation_schema.GLOBAL_VARIABLESview to view the values of global system variables.Session level
Both the
systenant and all user tenants can use theSHOW VARIABLESstatement and theinformation_schema.SESSION_VARIABLESview to view the values of session system variables.
Modify variables
Global effective
The
systenant can directly modify the values of global system variables.The user tenant must have the
SUPERorALTER SYSTEMprivilege to modify the value of a global system variable.
Session takes effect
The
systenant and all user tenants can directly modify the values of session system variables for their own tenants.
Attributes
Attribute |
Description |
|---|---|
| Parameter type | Bool |
| Default Value | OFF |
| Value range |
|
| Effective Scope |
|
| Modifiable | Yes, you can use theSETStatement modification. |
Usage instructions
Assume there is a table named t1, and its creation statement is as follows:
obclient> CREATE TABLE t1 (auto_inc_column auto_increment, j int);
When 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();
Configuration example
Set this parameter to allow direct queries using the IS NULL condition to retrieve the auto-increment column value of the last inserted row.
Session level
obclient> SET sql_auto_is_null = on;Global level
obclient> SET GLOBAL sql_auto_is_null = on;