CURRENT RULES

CURRENT RULES specifies whether certain 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. The table summarizes when the statements are affected and shows where to find detailed information. CURRENT RULES also affects whether DB2 issues an existence error (SQLCODE -204) or an authorization error (SQLCODE -551) when an object does not exist. For CURRENT RULES 'STD', DB2 issues an authorization error (SQLCODE -551) when an object does not exist instead of the existence error (SQLCODE -204).

Table 1. Summary of statements affected by CURRENT RULES
Statement What is affected Details in topic
ALTER TABLE 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.

Whether DB2 creates an index for an added ROWID column that is defined with GENERATED BY DEFAULT.

ALTER TABLE
CREATE TABLE 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.

Whether DB2 creates an index for a ROWID column that is defined with GENERATED BY DEFAULT if the table is explicitly created.

CREATE TABLE
GRANT Granting privileges to yourself. GRANT
REVOKE Revoking privileges from authorization IDs REVOKE
Example: 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';