CONSTRAINT_TABLE_USAGE

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 11.1 and above

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:

Name

Data type

Nullable

Standard

Description

TABLE_CATALOG

STRING

No

Yes

Catalog containing the relation.

TABLE_SCHEMA

STRING

No

Yes

Schema containing the relation.

TABLE_NAME

STRING

No

Yes

Name of the relation.

CONSTRAINT_CATALOG

STRING

No

Yes

Catalog containing the constraint.

CONSTRAINT_SCHEMA

STRING

No

Yes

Schema containing the constraint.

CONSTRAINT_NAME

STRING

No

Yes

Name of the constraint.

Constraints

The following constraints apply to the CONSTRAINT_TABLE_USAGE relation:

Class

Name

Column List

Description

Primary key

CON_TAB_USG_PK

TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME

Uniquely identifies the relation.

Foreign key

CON_TAB_USG_TABLES_FK

TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME

References TABLES

Foreign key

CON_TAB_USG_TAB_CONS_FK

CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME

References TABLE_CONSTRAINTS.

Examples

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