CONSTRAINT_COLUMN_USAGE
Applies to: Databricks SQL Databricks Runtime 11.3 LTS and above Unity Catalog only
Preview
This feature is in Public Preview.
INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE lists all constraints that reference columns as either foreign or primary key columns within the catalog.
The rows returned are limited to the tables the user is privileged to interact with.
Definition
The CONSTRAINT_COLUMN_USAGE
relation contains the following columns:
Name |
Data type |
Nullable |
Standard |
Description |
---|---|---|---|---|
|
|
No |
Yes |
Catalog containing the relation. |
|
|
No |
Yes |
Schema containing the relation. |
|
|
No |
Yes |
Name of the relation. |
|
|
No |
Yes |
Name of the column. |
|
|
No |
Yes |
Catalog containing the constraint. |
|
|
No |
Yes |
Schema containing the constraint. |
|
|
No |
Yes |
Name of the constraint. |
Constraints
The following constraints apply to the CONSTRAINT_COLUMN_USAGE
relation:
Class |
Name |
Column List |
Description |
---|---|---|---|
Primary key |
|
|
Uniquely identifies the column usage. |
Foreign key |
|
|
References TABLE_CONSTRAINTS. |
Foreign key |
|
|
References COLUMNS. |
Examples
> SELECT constraint_name
FROM information_schema.constraint_column_usage AS ccu
JOIN information_schema.table_constraints AS tc USING (constraint_catalog, constraint_schema, constraint_name)
WHERE ccu.table_schema = 'information_schema'
AND ccu.table_name = 'tables'
AND tc.constraint_type = 'PRIMARY KEY'