Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Default values
4. DEFAULT—explanation
How to auto-generate values in a database
Summary

Instruction

Okay. Let's start with DEFAULT.

The DEFAULT clause allows us to assign a default value to a column. DEFAULT is defined for a column during table creation, and the database architect decides whether a given column has a default value or not. The user only needs to know that a default value is defined for a particular column.

Technically, the default value is a constraint that says if there is no value added to this column during an INSERT or UPDATE operation, the specified default value will be used.

In our database, the Author table has default values for the following columns:

  • Photo (the path to the No photo picture).
  • CreateDateTime.
  • IsActive (default value of 0).

The Post table has a default value for ModifiedDateTime.

Exercise

Click Next exercise to continue.