Database Tutorial

Course Tutorial Site

Site Admin

Constraints

without comments

Week 2: Articles

Constraint Types

Learning Outcomes

  • Learn how to create, modify, and remove constraints.
  • Learn how constraints work.

Lesson Materials

There are five types of constraints that you may assign to tables. They are:

    NOT NULL Constraint

    NOT NULL constraints let you make a column mandatory when inserting or updating a row in the table.
    CHECK Constraint

    CHECK constraints let you verify the contents that you insert or update in a column based on literal, regular expression, or other column(s) value comparisons.
    UNIQUE Constraint

    UNIQUE constraints let you make a column or set of columns unique values within all rows of a table and they build an implicit index to enforce the constraint.
    PRIMARY KEY Constraint

    PRIMARY KEY constraints let you identify a column or set of columns as the primary key of a table. You typically assign a surrogate or sequence generated single column as a primary key column; or you assign a collection of descriptive columns that are unique as a natural key for the subject of the table.
    FOREIGN KEY Constraint

    FOREIGN KEY constraints let you identify a column or set of columns as a copy of a primary key from another table or from a copy of the same table where you define the foreign key.

Written by michaelmclaughlin

August 7th, 2018 at 12:51 am

Posted in