O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required