Beginner

127. DEFAULT Value

Understand how DEFAULT values can automatically provide values when data is inserted.

📘 Lesson 127 of 728 ⏱ 8 min 🎯 Beginner

A DEFAULT constraint specifies a value that the database can automatically use for a column when an INSERT statement does not provide a value for that column.

Defaults help maintain consistent data and reduce the need for applications or users to explicitly provide common values.

A new employee record may automatically receive an Active status when no status is provided.

SQL
CREATE TABLE Employees (
    EmployeeID INT,
    EmployeeName VARCHAR(100),
    Status VARCHAR(20) DEFAULT 'Active'
);

DEFAULT values are commonly used for statuses, creation dates, flags, quantities, and other fields with common starting values.

  • DEFAULT provides an automatic value.
  • It is defined at the column level.
  • It can simplify INSERT operations.
  • It helps maintain consistent data.
  • The default is used when a value is not supplied.
What is a DEFAULT constraint?

A DEFAULT constraint specifies a value that the database can automatically use when no value is provided.

Why use DEFAULT values?

They reduce manual input and help maintain consistent values in database records.

Have you finished this lesson?

Introduction to SQL – All Lessons