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


Okay. Let's start with DEFAULT.

The DEFAULT clause allows us to assign a default value to a column. DEFAULT is defined 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 has been 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).
  • create_timestamp (The default value is the current date and time.)
  • is_active (The default value is false).

The post table has a default value for modified_timestamp.


Click Next exercise to continue.