Skip to main content

table_constraints

Creates, updates, deletes, gets or lists a table_constraints resource.

Overview

Nametable_constraints
TypeResource
Iddatabricks_workspace.catalog.table_constraints

Fields

The following fields are returned by SELECT queries:

SELECT not supported for this resource, use SHOW METHODS to view available operations for the resource.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
createinsertdeployment_name, full_name_arg, constraintCreates a new table constraint.
deletedeletefull_name, constraint_name, cascade, deployment_nameDeletes a table constraint.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
cascadebooleanIf true, try deleting all child constraints of the current constraint. If false, reject this operation if the current constraint has any child constraints.
constraint_namestringThe name of the constraint to delete.
deployment_namestringThe Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc)
full_namestringFull name of the table referenced by the constraint.

INSERT examples

Creates a new table constraint.

INSERT INTO databricks_workspace.catalog.table_constraints (
full_name_arg,
constraint,
deployment_name
)
SELECT
'{{ full_name_arg }}' /* required */,
'{{ constraint }}' /* required */,
'{{ deployment_name }}'
RETURNING
foreign_key_constraint,
named_table_constraint,
primary_key_constraint
;

DELETE examples

Deletes a table constraint.

DELETE FROM databricks_workspace.catalog.table_constraints
WHERE full_name = '{{ full_name }}' --required
AND constraint_name = '{{ constraint_name }}' --required
AND cascade = '{{ cascade }}' --required
AND deployment_name = '{{ deployment_name }}' --required
;