Understanding Constraints
Constraints allow you to define rules for values allowed in columns (Table 10.1). Your DBMS uses these rules to enforce the integrity of the database automatically. Constraints come in two flavors:
A column constraint is part of a column definition and imposes a condition on that column only.
A table constraint is declared independently of a column definition and can impose a condition on more than one column in a table. You must use a table constraint to include more than one column in a constraint.
You can specify some constraints as either column or table constraints, depending on the context in which they’re used. If a primary key contains one column, for example, you can define it as a column constraint or as a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access