Skip to main content

CONSTRAINT_TABLE_USAGE

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 11.3 LTS and above check marked yes Unity Catalog only

Preview

This feature is in Public Preview.

INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE lists all constraints that reference a table as either a foreign or primary key within the catalog.

The rows returned are limited to the tables the user is privileged to interact with.

Definition

The CONSTRAINT_TABLE_USAGE relation contains the following columns:

NameData typeNullableStandardDescription
TABLE_CATALOGSTRINGNoYesCatalog containing the relation.
TABLE_SCHEMASTRINGNoYesSchema containing the relation.
TABLE_NAMESTRINGNoYesName of the relation.
CONSTRAINT_CATALOGSTRINGNoYesCatalog containing the constraint.
CONSTRAINT_SCHEMASTRINGNoYesSchema containing the constraint.
CONSTRAINT_NAMESTRINGNoYesName of the constraint.

Constraints

The following constraints apply to the CONSTRAINT_TABLE_USAGE relation:

ClassNameColumn ListDescription
Primary keyCON_TAB_USG_PKTABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAMEUniquely identifies the relation.
Foreign keyCON_TAB_USG_TABLES_FKTABLE_CATALOG, TABLE_SCHEMA, TABLE_NAMEReferences TABLES
Foreign keyCON_TAB_USG_TAB_CONS_FKCONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAMEReferences TABLE_CONSTRAINTS.

Examples

SQL
> SELECT constraint_name
FROM information_schema.constraint_table_usage
WHERE table_schema = 'information_schema'
AND table_name = 'tables'