Skip to main content

REFERENTIAL_CONSTRAINTS

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

Preview

This feature is in Public Preview.

INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS describes the referential integrity (RI) relationships between foreign keys and primary keys.

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

Definition

The REFERENTIAL_CONSTRAINTS relation contains the following columns:

NameData typeNullableStandardDescription
CONSTRAINT_CATALOGSTRINGNoYesCatalog containing the foreign key constraint.
CONSTRAINT_SCHEMASTRINGNoYesSchema containing the foreign key constraints.
CONSTRAINT_NAMESTRINGNoYesName of the check constraint.
UNIQUE_CONSTRAINT_CATALOGSTRINGNoYesCatalog containing the referenced constraint.
UNIQUE_CONSTARINT_SCHEMASTRINGNoYesSchema containing the referenced constraint.
UNIQUE_CONSTRAINT_NAMESTRINGNoYesName of the referenced constraint.
MATCH_OPTIONSTRINGNoYesAlways FULL, reserved for future use..
UPDATE_RULESTRINGNoYesAlways NO ACTION, reserved for future use.
DELETE_RULESTRINGNoYesAlways NO ACTION, reserved for future use.

Constraints

The following constraints apply to the REFERENTIAL_CONSTRAINTS relation:

ClassNameColumn ListDescription
Primary keyREF_CONS_PKCONSTRAINT_CATALOG,CONSTRAINT_SCHEMA, CONSTRAINT_NAMEUnique identifier for the constraint.
Foreign keyREF_CONS_TAB_CONS_FK_FKCONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAMEReferences TABLE_CONSTRAINTS.
Foreign keyREF_CONS_TAB_CONS_UC_FKUNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAMEReferences TABLE_CONSTRAINTS.

Examples

SQL
> SELECT constraint_name, check_clause
FROM information_schema.referential_constraints
WHERE table_schema = 'information_schema';