How Db2 resolves unqualified names

A plan or package can contain SQL statements that use unqualified table and view names.

Begin general-use programming interface information.For static SQL, the default qualifier for those names is the owner of the plan or package. However, you can use the QUALIFIER option of the BIND command to specify a different qualifier. For static statements, the PATH bind option determines the path that Db2 searches to resolve unqualified distinct types, user-defined functions, stored procedures, sequences, and trigger names.

When you perform bind operations on packages or plans that contain static SQL, you should use group and ROLE authority rather than individual ID authority whenever possible. The combinations of OWNER, QUALIFIER, SCHEMA, and ROLE ownership provide you more flexibility.

For plans or packages that contain dynamic SQL, DYNAMICRULES behavior determines how Db2 qualifies unqualified object names. For unqualified distinct types, user-defined functions, stored procedures, sequences, and trigger names in dynamic SQL statements, Db2 uses the schema name as the qualifier. Db2 finds the schema name in the CURRENT PATH special register. For unqualified tables, views, aliases, and indexes, Db2 uses the CURRENT SCHEMA special register as the qualifier.

Exception: ALTER, CREATE, DROP, COMMENT ON, GRANT, and REVOKE statements follow different conventions for assigning qualifiers. For static SQL, you must specify the qualifier for these statements in the QUALIFIER bind option. For dynamic SQL, the qualifier for these statements is the value in the CURRENT SCHEMA special register. End general-use programming interface information.