CURRENT RULES special register

CURRENT RULES specifies whether SQL statements are executed in accordance with Db2 rules or the rules of the SQL standard.

The data type of the register is CHAR(3), and the only valid values are 'DB2' and 'STD'.

CURRENT RULES is a register at the database server. If the server is not the local Db2, the initial value of the register is 'DB2'. Otherwise, the initial value is the same as the value of the SQLRULES bind option. The initial value of CURRENT RULES in a user-defined function or stored procedure is inherited according to the rules in Special registers in a user-defined function or a stored procedure.

You can change the value of the register by executing the statement SET CURRENT RULES.

CURRENT RULES affects the statements listed in the following table, which summarizes when the statements are affected and shows where to find more information.

Table 1. Summary of statements affected by CURRENT RULES
Statement What is affected
All statements
The type of SQL error code Db2 issues for any SQL statements that reference object names that do not exist.
  • When the CURRENT RULES value is 'DB2', Db2 issues an existence error such as SQLCODE -204 for an object that does not exist.
  • When the CURRENT RULES value is 'STD', Db2 issues an authorization error such as SQLCODE -551 for an object that does not exist.
ALTER TABLE The following behaviors:
  • Enforcement of check constraints added.
  • Default value of the delete rule for referential constraints.
  • Whether Db2 creates LOB table spaces, auxiliary tables, and indexes on auxiliary tables for added LOB columns. See LOB table space implicit creation.
  • Whether Db2 creates an index for an added ROWID column that is defined with GENERATED BY DEFAULT.
CREATE TABLE The following behaviors:
  • Default value of the delete rule for referential constraints.
  • Whether Db2 creates LOB table spaces, auxiliary tables, and indexes on auxiliary tables for LOB columns if the table is explicitly created. See LOB table space implicit creation.
  • Whether Db2 creates an index for a ROWID column that is defined with GENERATED BY DEFAULT if the table is explicitly created.
GRANT Granting privileges to yourself.
REVOKE Revoking privileges from authorization IDs.
Set CURRENT RULES so that a later ALTER TABLE statement is executed in accordance with the rules of the SQL standard:
  SET CURRENT RULES = 'STD';