Skip to main content

Table Constraint

View as Markdown

A table constraint, as defined by one of the following fields being set: primary_key_constraint, foreign_key_constraint, named_table_constraint.

TableConstraint object

A table constraint, as defined by one of the following fields being set: primary_key_constraint, foreign_key_constraint, named_table_constraint.

primary_key_constraintobject
Show child attributesHide child attributes
namestring

The name of the constraint.

child_columnsarray of string

Column names for this constraint.

timeseries_columnsarray of string

Column names that represent a timeseries.

relyboolean

True if the constraint is RELY, false or unset if NORELY.

foreign_key_constraintobject
Show child attributesHide child attributes
namestring

The name of the constraint.

child_columnsarray of string

Column names for this constraint.

parent_tablestring

The full name of the parent constraint.

parent_columnsarray of string

Column names for this constraint.

relyboolean

True if the constraint is RELY, false or unset if NORELY.

named_table_constraintobject
Show child attributesHide child attributes
namestring

The name of the constraint.

Create GA

POST /api/2.1/unity-catalog/constraints

Creates a new table constraint.

For the table constraint creation to succeed, the user must satisfy both of these conditions:

  • the user must have the USE_CATALOG privilege on the table's parent catalog, the USE_SCHEMA privilege on the table's parent schema, and be the owner of the table.
  • if the new constraint is a ForeignKeyConstraint, the user must have the USE_CATALOG privilege on the referenced parent table's catalog, the USE_SCHEMA privilege on the referenced parent table's schema, and be the owner of the referenced parent table.

API scopes: unity-catalog

Request body

full_name_argstringRequired

The full name of the table referenced by the constraint.

constraintobjectRequired
Show child attributesHide child attributes
primary_key_constraintobject
Show child attributesHide child attributes
namestringRequired

The name of the constraint.

child_columnsarray of stringRequired

Column names for this constraint.

timeseries_columnsarray of string

Column names that represent a timeseries.

relyboolean

True if the constraint is RELY, false or unset if NORELY.

foreign_key_constraintobject
Show child attributesHide child attributes
namestringRequired

The name of the constraint.

child_columnsarray of stringRequired

Column names for this constraint.

parent_tablestringRequired

The full name of the parent constraint.

parent_columnsarray of stringRequired

Column names for this constraint.

relyboolean

True if the constraint is RELY, false or unset if NORELY.

named_table_constraintobject
Show child attributesHide child attributes
namestringRequired

The name of the constraint.

Response

Returns the TableConstraint object.

Delete GA

DELETE /api/2.1/unity-catalog/constraints/{full_name_arg}

Deletes a table constraint.

For the table constraint deletion to succeed, the user must satisfy both of these conditions:

  • the user must have the USE_CATALOG privilege on the table's parent catalog, the USE_SCHEMA privilege on the table's parent schema, and be the owner of the table.
  • if cascade argument is true, the user must have the following permissions on all of the child tables: the USE_CATALOG privilege on the table's catalog, the USE_SCHEMA privilege on the table's schema, and be the owner of the table.

API scopes: unity-catalog

Parameters

full_name_argstringRequiredpath

Full name of the table referenced by the constraint.

constraint_namestringRequiredquery

The name of the constraint to delete.

cascadebooleanRequiredquery

If true, try deleting all child constraints of the current constraint. If false, reject this operation if the current constraint has any child constraints.

Default: false