---
title: "CHECK constraint"
description: "A CHECK constraint is a rule attached to a table column (or the table as a whole) that requires every row to satisfy a given boolean expression."
canonical: "https://motherduck.com/glossary/check-constraint/"
related:
  - title: "Constraints | MotherDuck Docs"
    url: "https://motherduck.com/docs/sql-reference/duckdb-sql-reference/constraints/"
  - title: "Analyze JSON Data Using SQL and DuckDB"
    url: "https://motherduck.com/blog/analyze-json-data-using-sql/"
  - title: "DuckDB statements | MotherDuck Docs"
    url: "https://motherduck.com/docs/sql-reference/duckdb-sql-reference/duckdb-statements/"
gated_asset:
  title: "DuckLake: The Lakehouse Table Format"
  url: "https://motherduck.com/lp/ducklake-lakehouse-table-format-book-full/"
---

# CHECK constraint

> A CHECK constraint is a rule attached to a table column (or the table as a whole) that requires every row to satisfy a given boolean expression.

## Overview

A `CHECK` constraint lets you enforce business rules directly in the schema instead of relying on application code to validate every write. Any `INSERT` or `UPDATE` that would produce a row violating the expression is rejected by the database with a constraint error, so invalid data can never make it into the table regardless of which application or script wrote it.

<glossary-callout guide="duckdb-cheatsheet-full" />

## Syntax

`CHECK` constraints can be attached to a single column or defined at the table level to reference multiple columns:

```sql
CREATE TABLE orders (
    id INTEGER PRIMARY KEY,
    quantity INTEGER CHECK (quantity > 0),
    discount_pct DECIMAL,
    CHECK (discount_pct >= 0 AND discount_pct <= 100)
);
```

## Use Cases

`CHECK` constraints are commonly used to enforce value ranges (a price can't be negative), simple cross-column invariants (a start date must precede an end date), or restricting a column to a fixed set of values when an enum type isn't a good fit.

## DuckDB Support

DuckDB supports `CHECK` constraints with the same syntax shown above, evaluated at insert and update time. Because DuckDB is often used for bulk analytical loads, it's worth remembering that a `CHECK` constraint violation anywhere in a batch load will fail the whole statement — for very large loads it can be faster to validate data before loading and rely on `CHECK` as a safety net rather than a primary cleaning step.
