MySQL DatabaseLesson 58Free preview
MySQL Default
This lesson is part of MySQL · All levels
Summary
The default constraint assigns an in-built value to a column so that the value does not have to be written always when INSERT. These default values can be either literal such as 0 or 'active', or expressions such as CURRENT_TIMESTAMP. DEFAULT is often used with NOT NULL to keep the column always filled even if the user does not submit the value.
Key points
- Default automatically fills in the values when the column is not called when INSERT
- The default value can be either literal or expressive, for example CURRENT_TIMESTAMP
- Default is only used when the column does not accept an explicit value
- Change the default with the ALTER TABLE ALTER COLUMN SET the default
- DEFAULT and NOT complement each other so that data is always filled
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.