Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Default values
4. DEFAULT—explanation
Summary

Instruction

Okay, let's explain 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 or not a given column has a default value. 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 that 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 (default value of 'imgs/no-photo.jpg')
  • create_timestamp
  • is_active (default value of false)

The post table has a default value for modified_timestamp.

Exercise

Click Next exercise to continue.