SQL DatabaseLesson 58Free preview
SQL Default
This lesson is part of SQL · All levels
Summary
The default constraint provides an inbuilt value to the column when INSERT does not include the column. DEFAULT saves repeated data writing and ensures that the columns remain properly filled. The default value must be compatible with the data type of the column.
Key points
- Default sets the built-in value of the column when the value is not specified.
- Defined when CREATE TABLE or added via ALTER TABLE.
- The default value must be in accordance with the column data type.
- The default CURRENT_TIMESTAMP is useful for creating time columns.
- Default does not help when INSERT fills the column with NULL on the NOT NULL column.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.