TABLE_SCHEMA

The TABLE_SCHEMA function returns the schema name of the object found for an alias.

Read syntax diagramSkip visual syntax diagramTABLE_SCHEMA (object-name,object-schema)

The specified object-name (and object-schema) are used to find an alias by that name.

object-name
A character or graphic string expression that identifies the SQL or system name of the object to be resolved. object-name must have an actual length less than 129 characters and may not identify a blank name. This name is case sensitive and must not be delimited.
object-schema
A character or graphic string expression that identifies the SQL or system name of the schema used to qualify object-name. object-schema must have an actual length less than 129 characters and may not identify a blank name. This name is case sensitive and must not be delimited.

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

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 a schema name.

The result name is the schema name of the table or view referenced by the alias. If object-name is not an alias name, object-schema is returned.

Start of change

Example

Get the name of the schema referenced by an alias that was created like this:
CREATE ALIAS MYLIB2.ALIAS1 FOR MYLIB.EMPLOYEE


VALUES TABLE_SCHEMA('ALIAS1', 'MYLIB2')
The result is:
MYLIB
End of change