CHECK
A constraint that each row must satisfy a condition, such as quantity > 0 or a status from a fixed list.
In more detail
The database refuses any insert or update that makes the condition false. It protects allowed values at the source, whichever program does the writing.
Example
status TEXT NOT NULL CHECK (status IN ('paid', 'pending', 'refunded'))Related terms
- constraint — A rule the database enforces on stored data, such as a column that must be unique or not null.
- predicate — A function or condition that answers true or false about a value, used to filter, search or check data.
Taught in
- Data Types And What To Choose — PostgreSQL, Indexing & Relational Data Modeling
- Keys, Constraints And Referential Integrity — PostgreSQL, Indexing & Relational Data Modeling
- Inserting Data Safely — PostgreSQL, Indexing & Relational Data Modeling