DB2 Version 9.7 for Linux, UNIX, and Windows

TABLE_NAME scalar function

Read syntax diagramSkip visual syntax diagram
>>-TABLE_NAME--(--object-name--+------------------+--)---------><
                               '-,--object-schema-'      

The schema is SYSIBM.

The TABLE_NAME function returns an unqualified name of the object found after any alias chains have been resolved. The specified object-name (and object-schema) are used as the starting point of the resolution. If the starting point does not refer to an alias, the unqualified name of the starting point is returned. The resulting name may be of a table, view, or undefined object. In a Unicode database, if a supplied argument is a graphic string, it is first converted to a character string before the function is executed.

object-name
A character expression representing the unqualified name (usually of an existing alias) to be resolved. object-name must have a data type of CHAR or VARCHAR and a length greater than 0 and less than 129 bytes.
object-schema
A character expression representing the schema used to qualify the supplied object-name value before resolution. object-schema must have a data type of CHAR or VARCHAR and a length greater than 0 and less than 129 bytes.

If object-schema is not supplied, the default schema is used for the qualifier.

The data type of the result of the function is VARCHAR(128). If object-name can be null, the result can be null; if object-name is null, the result is the null value. If object-schema is the null value, the default schema name is used. The result is the character string representing an unqualified name. The result name could represent one of the following:
table
The value for object-name was either a table name (the input value is returned) or an alias name that resolved to the table whose name is returned.
view
The value for object-name was either a view name (the input value is returned) or an alias name that resolved to the view whose name is returned.
undefined object

The value for object-name was either an undefined object (the input value is returned) or an alias name that resolved to the undefined object whose name is returned.

Therefore, if a non-null value is given to this function, a value is always returned, even if no object with the result name exists.

Note: To improve performance in partitioned database configurations by avoiding the unnecessary communication that occurs between the coordinator partition and catalog partition when using the TABLE_SCHEMA and TABLE_NAME scalar functions, the BASE_TABLE table function can be used instead.