The rules for forming a name depend on the type of the object designated
by the name and the naming option (*SQL or *SYS). The naming option is specified
on the CRTSQLxxx, RUNSQLSTM, and STRSQL commands. The SET OPTION statement
can be used to specify the naming option within the source of a program containing
embedded SQL. The syntax diagrams use different terms for different types
of names. The following list defines these terms.
- alias-name
- A qualified or unqualified name that designates an alias. The qualified
form of an alias-name depends on the naming option. For SQL naming,
the qualified form is a schema-name followed by a period (.) and
an SQL identifier. For system naming, the qualified form is a schema-name followed by a slash (/) followed by an SQL identifier.
The unqualified
form of an alias-name is an SQL identifier. The unqualified form
is implicitly qualified based on the rules specified in Qualification of unqualified object names.
An alias-name can specify either the name of the alias or
the system object name of the alias.
- authorization-name
- A system identifier that designates a user or group of users. An authorization-name is a user profile name on the server. It must not
be a delimited identifier that includes lowercase letters or special characters.
See Authorization IDs and authorization names for the distinction between an authorization-name and an authorization ID.
- column-name
- A qualified or unqualified name that designates a column of a table
or a view. The unqualified form of a column-name is an SQL identifier.
The qualified form is a qualifier followed by a period and an SQL identifier.
The qualifier is a table name, a view name, or a correlation name.
Column
names cannot be qualified with system names in the form schema-name/table-name.column-name, except in the COMMENT and LABEL statements.
If column names need to be qualified, and correlation names are allowed in
the statement, a correlation name must be used to qualify the column.
A column-name can specify either the column name or the system column
name of a column of a table or view. If a column-name is delimited,
the delimiters are considered to be part of the name when determining the
length of the name.
- constraint-name
- A qualified or unqualified name that designates a constraint on a table.
The qualified form of a constraint-name depends on the naming option.
For SQL naming, the qualified form is a schema-name followed by a
period (.) and a system identifier. For system naming, the qualified form
is a schema-name followed by a slash (/) followed by an SQL identifier.
The unqualified form of a constraint-name is an SQL identifier. The
unqualified form is implicitly qualified based on the rules specified in Qualification of unqualified object names.
- correlation-name
- An SQL identifier that designates a table, a view, or individual rows
of a table or view.
- cursor-name
- An SQL identifier that designates an SQL cursor.
- descriptor-name
- A variable name or string constant that designates an SQL descriptor
area (SQLDA). A variable that designates an SQL descriptor area must not have
an indicator variable. The form :host-variable:indicator-variable is
not allowed. See References to host variables for a description of a variable.
- distinct-type-name
- A qualified or unqualified name that designates a distinct type. The
qualified form of a distinct-type-name depends upon the naming option.
For SQL naming, the qualified form is a schema-name followed by a
period (.) and an SQL identifier. For system naming, the qualified form is
a schema-name followed by a slash (/) followed by an SQL identifier.
The unqualified form of a distinct-type-name is an SQL identifier.
The unqualified form is implicitly qualified based on the rules specified
in Qualification of unqualified object names.
For system naming, distinct-type-names cannot be qualified when used in a parameter data type of an SQL routine
or in an SQL variable declaration in an SQL function, SQL procedure, or trigger.
- external-program-name
- A qualified name, unqualified name, or a character string that designates
an external program. The qualified form of an external-program-name depends
on the naming option. For SQL naming, the qualified form is a schema-name followed by a period (.) and a system identifier. For system naming,
the qualified form is a schema-name followed by a slash (/) followed
by a system identifier.
The unqualified form of an external-program-name is a system identifier. The unqualified form is implicitly qualified
based on the rules specified in Qualification of unqualified object names.
The format of
the character string form is either:
- function-name
- A qualified or unqualified name that designates a user-defined function,
a cast function that was generated when a distinct type was created, or a
built-in function. The qualified form of a function-name depends
upon the naming option. For SQL naming, the qualified form is a schema-name followed by a period (.) and an SQL identifier. For system naming, the
qualified form is a schema-name followed by a slash (/) followed
by an SQL identifier.
The unqualified form of a function-name is
an SQL identifier. The unqualified form is implicitly qualified based on the
rules specified in Qualification of unqualified object names.
For system naming, functions
names can only be qualified in the form schema-name/function-name when the name is used in a CREATE, COMMENT, DROP, GRANT, or REVOKE statement.
- host-label
- A token that designates a label in a host program.
- host-variable
- A sequence of tokens that designates a host variable. A host-variable includes at least one host-identifier, as explained in References to host variables.
- index-name
- A qualified or unqualified name that designates an index. The qualified
form of an index-name depends upon the naming option. For SQL naming,
the qualified form is a schema-name followed by a period (.) and
an SQL identifier. For system naming, the qualified form is a schema-name followed by a slash (/) followed by an SQL identifier.
The unqualified
form of an index-name is an SQL identifier. The unqualified form
is implicitly qualified based on the rules specified in Qualification of unqualified object names.
- nodegroup-name
- A qualified or unqualified name that designates a nodegroup. A nodegroup
is a group of iSeries servers across which a table will be distributed. For
more information about distributed tables and nodegroups, see the DB2® Multisystem book.
The qualified form of a nodegroup-name depends on the
naming option. For SQL naming, the qualified form is a schema-name followed
by a period (.) and a system identifier. For system naming, the qualified
form is a schema-name followed by a slash (/) followed by a system
identifier.
The unqualified form of a nodegroup-name is a system
identifier. The unqualified form is implicitly qualified based on the rules
specified in Qualification of unqualified object names.
- package-name
- A qualified or unqualified name that designates a package. The qualified
form of a package-name depends upon the naming option. For SQL naming,
the qualified form is a schema-name followed by a period (.) and
a system identifier. For system naming, the qualified form is a schema-name followed by a slash (/) followed by a system identifier.
The unqualified
form of a package-name is a system identifier. The unqualified form
is implicitly qualified based on the rules specified in Qualification of unqualified object names.
- parameter-name
- An SQL identifier that designates a parameter for a function or procedure.
If the parameter-name is for a procedure, the identifier may be
preceded by a colon.
- partition-name
- An unqualified identifier that designates a partition of a partitioned
table.
- procedure-name
- A qualified or unqualified name that designates a procedure. The qualified
form of a procedure-name depends upon the naming option. For SQL
naming, the qualified form is a schema-name followed by a period
(.) and an SQL identifier. For system naming, the qualified form is a schema-name followed by a slash (/) followed by an SQL identifier.
The unqualified form of a procedure-name is an SQL identifier. The
unqualified form is implicitly qualified based on the rules specified in Qualification of unqualified object names.
- savepoint-name
- An unqualified identifier that designates a savepoint.
- schema-name
- A qualified or unqualified name that provides a logical grouping for
SQL objects. A schema name is used as a qualifier of the name of a table,
view, index, procedure, function, trigger, constraint, alias, type, or package.
The unqualified form of a schema-name is a system identifier. The
qualified form of a schema-name depends on the naming option.
For SQL names, the unqualified schema name in an SQL statement is implicitly
qualified by the server-name. The qualified form is a server-name followed by a (.) and a system identifier. The server-name must
identify the current server.
For system names, the unqualified schema
name in an SQL statement is implicitly qualified by the server-name.
The qualified form is a server-name followed by a slash (/) and a
system identifier. The server-name must identify the current server.
Note:
schema-name refers to either a schema created
by the CREATE SCHEMA statement or to an i5/OS library.
- sequence-name
- A qualified or unqualified name that designates a sequence.
The qualified form of a sequence-name depends upon the naming option.
For SQL naming, the qualified form is a schema-name followed by a
period (.) and an SQL identifier. For system naming, the qualified form is
a schema-name followed by a slash (/) followed by an SQL identifier. For system naming, a sequence-name cannot be qualified
when used in a NEXT VALUE or PREVIOUS VALUE expression (the qualified form
is only allowed in SQL schema statements).
The unqualified form of
a sequence-name is an SQL identifier. The unqualified form is implicitly
qualified based on the rules specified in Qualification of unqualified object names.
A sequence-name can specify either the name of the sequence or the system
object name of the sequence.
- server-name
- An SQL identifier that designates an application server. The identifier must
start with a letter and must not include lowercase letters or special characters.
- specific-name
- A qualified or unqualified name that uniquely identifies a procedure
or function. The qualified form of a specific-name depends upon the
naming option. For SQL naming, the qualified form is a schema-name followed
by a period (.) and an SQL identifier. For system naming, the qualified form
is a schema-name followed by a slash (/) followed by an SQL identifier.
The unqualified form of a specific-name is an SQL identifier. The
unqualified form is implicitly qualified based on the rules specified in Qualification of unqualified object names.
- SQL-descriptor-name
- A variable name or character or graphic string constant that designates
an SQL descriptor that was allocated using the ALLOCATE DESCRIPTOR statement.
If a variable is used to designate the SQL descriptor:
- The variable must not be a CLOB or DBCLOB.
- If the variable is a graphic string, it must be a UTF-16 or UCS-2 graphic
string.
- The length of the contents of the variable must not exceed the maximum
length for an SQL-descriptor-name.
- An indicator variable must not be specified. The form :host-variable:indicator-variable is not allowed.
- The contents of the variable are case-sensitive and are not converted
to uppercase.
Leading and trailing blanks are trimmed from the variable or string.
See References to host variables for a description of a variable.
If a string
constant is used to designate the SQL descriptor, the length of the constant
must not exceed the maximum length for an SQL-descriptor-name.
- SQL-label
- An unqualified name that designates a label in an SQL procedure, SQL
function, or trigger body. An SQL-label is an SQL identifier.
- SQL-parameter-name
- A qualified or unqualified name that designates a parameter in an SQL
routine body. The unqualified form of an SQL-parameter-name is an
SQL identifier. The qualified form is a procedure-name followed by
a period (.) and an SQL identifier.
- SQL-variable-name
- A qualified or unqualified name that designates a variable in an SQL
routine body. The unqualified form of an SQL-variable-name is an
SQL identifier. The qualified form is an SQL-label followed by a
period (.) and an SQL identifier.
- statement-name
- An SQL identifier that designates a prepared SQL statement.
- system-column-name
- An unqualified name that designates the i5/OS column name of a table
or a view. A system-column-name is a system identifier. System-column-names can be delimited identifiers, but the characters within the delimiters
must not include lowercase letters or special characters.
- system-object-name
- An unqualified name that designates the i5/OS name of a table, view,
index, sequence, or alias. A system-object-name is a system identifier.
If the unqualified name of the table, view, index, sequence, or alias is a
valid system identifier, the system-object-name of the table, view,
index, sequence, or alias is the unqualified name of the table, view, index,
sequence, or alias.
- table-name
- A qualified or unqualified name that designates a table. The qualified
form of a table-name depends upon the naming option. For SQL naming,
the qualified form is a schema-name followed by a period (.) and
an SQL identifier. For system naming, the qualified form is a schema-name followed by a slash (/) followed by an SQL identifier.
The unqualified
form of a table-name is an SQL identifier. The unqualified form is
implicitly qualified based on the rules specified in Qualification of unqualified object names.
A table-name can specify either the name of the table or the
system object name of the table.
- trigger-name
- A qualified or unqualified name that designates a trigger on a table.
The qualified form of a trigger-name depends on the naming option.
For SQL naming, the qualified form is a schema-name followed by a
period (.) and a system identifier. For system naming, the qualified form
is a schema-name followed by a slash (/) followed by an SQL identifier.
The unqualified form of a trigger-name is an SQL identifier. The
unqualified form is implicitly qualified based on the rules specified in Qualification of unqualified object names.
- version-id
- An identifier of 1 to 64 characters that is assigned to a package when
the package is created. A version-id is only assigned when packages
are created from a server other than DB2 UDB for iSeries.
- view-name
- A qualified or unqualified name that designates a view. The qualified
form of a view-name depends upon the naming option. For SQL naming,
the qualified form is a schema-name followed by a period (.) and
an SQL identifier. For system naming, the qualified form is a schema-name followed by a slash (/) followed by an SQL identifier.
The unqualified
form of a view-name is an SQL identifier. The unqualified form is
implicitly qualified based on the rules specified in Qualification of unqualified object names.
A view-name can specify either the name of the view or the
system object name of the view.
Table 2. Identifier Length Limits (in bytes)
Identifier Type |
Maximum Length |
Longest authorization name17 |
10 |
Longest condition name |
128 |
Longest correlation name |
128 |
Longest cursor name |
18 |
Longest external program name (unqualified
form)18 |
10 |
Longest external program name (string form) |
279 |
Longest host identifier |
64 |
Longest partition name |
10 |
Longest savepoint name |
128 |
Longest schema name |
10 |
Longest server name |
18 |
Longest SQL-descriptor-name |
128 |
Longest SQL label |
128 |
Longest statement name |
18 |
Longest unqualified alias name |
128 |
Longest unqualified column name |
128 |
Longest unqualified constraint name |
128 |
Longest unqualified distinct type name |
128 |
Longest unqualified function name |
128 |
Longest unqualified index name |
128 |
Longest unqualified nodegroup name |
10 |
Longest unqualified package name |
10 |
Longest package version-id |
64 |
Longest unqualified parameter name |
128 |
Longest unqualified procedure name |
128 |
Longest unqualified sequence name |
128 |
Longest unqualified specific name |
128 |
Longest unqualified SQL parameter name |
128 |
Longest unqualified SQL variable name |
128 |
Longest unqualified system column name |
10 |
Longest unqualified system object name |
10 |
Longest unqualified table and view name |
128 |
Longest unqualified trigger name |
128 |
The SQL path is an ordered list of schema names.
The database manager uses the path to resolve the schema name for unqualified
distinct type names (both built-in types and distinct types), function names,
and procedure names that appear in any context other than as the main object
of a CREATE, DROP, COMMENT, GRANT or REVOKE statement. Searching through the
path from left to right, the database manager implicitly qualifies the object name with
the first schema name in the path that contains the same object with the same
unqualified name. For procedures, the database manager selects a matching procedure name
only if the number of parameters is also the same. For functions, the database manager uses
a process called function resolution in conjunction with the SQL path to determine
which function to choose because several functions with the same name can
reside in a schema. (For details, see Function resolution.)
For example, if the SQL path is SMITH, XGRAPHIC, QSYS, QSYS2 and an unqualified
distinct type name MYTYPE was specified, the database manager looks for MYTYPE first in
schema SMITH, then XGRAPHIC, and then QSYS and QSYS2.
The path used is determined as follows:
- For all static SQL statements (except for a CALL variable statement), the path used is the value of the SQLPATH parameter
on the CRTSQLxxx command. The SQLPATH can also be set using the SET OPTION
statement.
- For dynamic SQL statements (and for a CALL variable statement), the path used is the value of the CURRENT PATH special
register. For more information about the CURRENT PATH special register, see CURRENT PATH.
If the SQL path is not explicitly specified, the SQL path is the system
path followed by the authorization ID of the statement.
For more information on the SQL path for dynamic SQL, see CURRENT PATH.
Unqualified object names are implicitly qualified. The rules for qualifying
a name differ depending on the type of object that the name identifies.
Unqualified alias, constraint, external program, index, nodegroup,
package, sequence, table, trigger, and view names
Unqualified alias, constraint, external program, index, nodegroup, package, sequence, table, trigger, and view names are implicitly qualified by
the default schema. The default schema is specified as follows:
- For static SQL statements:
- If the DFTRDBCOL parameter is specified on the CRTSQLxxx command (or with
the SET OPTION statement), the default schema is the schema-name that is specified for that parameter.
- In all other cases, the default schema is based on the naming
convention.
- For SQL naming, the default schema is the authorization identifier
of the statement.
- For system naming, the default schema is the job library list
(*LIBL).
- For dynamic SQL statements the default schema depends on whether
or not a default schema has been explicitly specified. The mechanism
for explicitly specifying this depends on the interface used to dynamically
prepare and execute SQL statements.
- If a default schema is not explicitly specified:
- For SQL naming, the default schema is the run-time authorization
identifier.
- For system naming, the default schema is the job library list
(*LIBL).
- The default schema is explicitly specified through the following
interfaces:
Table 3. Default Schema Interfaces
SQL Interface |
Specification |
Embedded SQL |
DFTRDBCOL parameter and DYNDFTCOL(*YES) on
the Create SQL Program (CRTSQLxxx) and Create SQL Package (CRTSQLPKG) commands.
The SET OPTION statement can also be used to set the DFTRDBCOL and DYNDFTCOL
values.
(For more information about CRTSQLxxx commands, see
the Embedded SQL Programming book.) |
Run SQL Statements |
DFTRDBCOL parameter on the Run SQL Statements
(RUNSQLSTM) command.
(For more information about the RUNSQLSTM
command, see the SQL Programming book.) |
Call Level Interface (CLI) on the server |
SQL_ATTR_DEFAULT_LIB or SQL_ATTR_DBC_DEFAULT_LIB
environment or connection variables
(For more information about
CLI, see the SQL Call Level Interfaces (ODBC) book.) |
JDBC or SQLJ on the server using IBM® Developer Kit for Java |
libraries property object
(For
more information about JDBC and SQLJ, see the IBM Developer Kit
for Java topic in the iSeries Information Center.) |
ODBC on a client using the iSeries Access Family ODBC Driver |
SQL Default Library in ODBC Setup
(For
more information about ODBC, see the iSeries Access category
in the iSeries Information Center.) |
JDBC on a client using the IBM Toolbox for Java |
SQL Default Library in JDBC Setup
(For
more information about JDBC, see the iSeries Access category
in the iSeries Information Center.)
(For more information about the IBM Toolbox for Java,
see IBM Toolbox for Java topic in the iSeries Information Center.) |
OLE DB on a client using the iSeries Access Family OLE DB
Provider |
Default Collection in Connection Object Properties
(For
more information about ODBC, see the iSeries Access category
in the iSeries Information Center.) |
All interfaces |
SET SCHEMA or QSQCHGDC (Change Dynamic Default
Collection) API
(For more information about QSQCHGDC, see the File APIs category in the iSeries Information Center.) |
Unqualified function, procedure, specific, and distinct type names
The qualification of data type (both built-in types and distinct types),
function, procedure, and specific names depends on the SQL statement in which
the unqualified name appears:
- If an unqualified name is the main object of a CREATE, COMMENT, DROP,
GRANT, or REVOKE statement, the name is implicitly qualified using the same
rules as for qualifying unqualified table names (See Unqualified alias, constraint, external program, index, nodegroup,
package, sequence, table, trigger, and view names).
- Otherwise, the implicit schema name is determined as follows:
- For distinct type names, the database manager searches the SQL path and selects the
first schema in the path such that the data type exists in the schema.
- For procedure names, the database manager searches the SQL path and selects the first
schema in the path such that the schema contains a procedure with the same
name and number of parameters.
- For function names and for specific names specified for sourced functions, the database manager uses
the SQL path in conjunction with function resolution, as described under Function resolution.
The CL command Override Database File (OVRDBF) can be specified to override
an SQL or system name with another object name for local data manipulation
SQL statements. Overrides are ignored for data definition SQL statements and
data manipulation SQL statements executing at a remote relational database.
See the File Management book for more information about
the override function.
As an application requester, iSeries™ can send
an authorization name of up to 255 bytes.
For REXX procedures,
the limit is 33.
[ Top of Page | Previous Page | Next Page | Contents |
Index ]