TABLE_SCHEMA

The TABLE_SCHEMA function searches for an object and returns the schema name of the object after any synonyms or alias chains have been resolved.

>>-TABLE_SCHEMA(-object-name-+-------------------------------------+-)-><
                             '-, object-schema-+-----------------+-'     
                                               '-, location-name-'       

The schema is DSN8.

The starting point of the resolution is the object that is specified by objectname and objectschema. If the starting point does not refer to an alias or synonym, the schema name of the starting point is returned. The resulting schema name can be of a table, view, or undefined object.

object-name
A character expression that specifies the unqualified name to be resolved. The unqualified name is usually of an existing alias. object-name must have a data type of VARCHAR and an actual length that is no greater than 18 bytes.
object-schema
A character expression that represents the schema that is used to qualify the value specified in object-name before resolution. object-schema must have a data type of VARCHAR and an actual length that is no greater than 8 bytes.

If object-schema is not specified or is null, the default schema is used for the qualifier.

location-name
A character expression that represents the location that is used to qualify the value specified in object-name before resolution. location-name must have a data type of VARCHAR (and an actual length that is no greater than 16 bytes.

If location-name is not specified or is null, the location name is equivalent to "any".

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.

The following table shows the external and specific names for TABLE_SCHEMA. The specific names differ depending on the number of input arguments.
Table 1. External and specific names for function TABLE_SCHEMA
Input arguments External name Specific name
object-name (VARCHAR)
DSN8DUTI DSN8.DSN8DUTISV
object-name (VARCHAR)
object-schema (VARCHAR)
DSN8DUTI DSN8.DSN8DUTISVV
object-name (VARCHAR)
object-schema (VARCHAR)
location-name (VARCHAR)
DSN8DUTI DSN8.DSN8DUTISVVV

Example: Assume that:

  • DSN8.ALIAS_OF_SYSTABLES is an alias of SYSIBM.SYSTABLES.
  • The CURRENT SQLID is DSN8.
Find the name of the schema of the base table for ALIAS_OF_SYSTABLES.
   VALUES DSN8.TABLE_SCHEMA( 'ALIAS_OF_SYSTABLES' );
The result of the function is 'SYSIBM'.