ALTER TABLE DROP CONSTRAINT

Drops a named CHECK or NOT NULL constraint from a Delta table.

Category: ddl

Syntax

ALTER TABLE <table> DROP CONSTRAINT [IF EXISTS] <constraint_name>

Description

## Overview ALTER TABLE DROP CONSTRAINT removes a previously declared CHECK or NOT NULL constraint by name. The constraint stops being enforced on subsequent writes; rows already in the table are unaffected. ## Behavior - The drop is recorded as a new commit on the parent table. The constraint is removed from the table's properties. - The cached snapshot for the table is invalidated so subsequent queries see the updated schema and stop enforcing the constraint. - Without IF EXISTS, dropping a non-existent constraint raises an error. With IF EXISTS, the operation succeeds with no commit. - Existing data that violates the dropped constraint stays in the table. The constraint's only effect was rejecting future writes; nothing is rewritten. - DROP CONSTRAINT only handles named constraints declared via ADD CONSTRAINT. NOT NULL constraints declared inline in CREATE DELTA TABLE are managed via ALTER COLUMN DROP NOT NULL, not this command. ## Access Control No specific privilege is required beyond table-level access in the standalone SQL layer. ## Compatibility Standard SQL syntax.

Parameters

NameTypeDescription
tableSpecifies the Delta table to alter.
constraint_nameSpecifies the constraint name to drop. Must match the name supplied at ADD CONSTRAINT.
if_existsSkip the operation silently when no constraint with that name exists on the table.

Examples

-- Drop a known CHECK constraint
ALTER TABLE products DROP CONSTRAINT price_positive;
-- Idempotent drop
ALTER TABLE customers DROP CONSTRAINT IF EXISTS email_required;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →