Default Value
ELI5 — The Vibe Check
A default value is what gets stored in a column when you do not provide one. Like 'created_at' defaulting to the current time — you never have to pass it in, the database fills it in for you automatically.
Real Talk
A DEFAULT value is a column-level constraint that specifies a value to use when no explicit value is provided during an INSERT. Defaults can be literals (0, 'active'), expressions (NOW()), or functions. They reduce the need for application-level logic.
Show Me The Code
CREATE TABLE tasks (
id SERIAL PRIMARY KEY,
status TEXT DEFAULT 'pending',
created_at TIMESTAMPTZ DEFAULT NOW()
);
When You'll Hear This
"Set the status column to default to 'active'." / "The created_at column has a default of the current timestamp."
Related Terms
Auto Increment
Auto increment means the database assigns the next ID number automatically every time you insert a row.
Column
A column is a category of data in a table. If a table is a spreadsheet, columns are the headers: 'Name', 'Email', 'Age'.
Not Null
NOT NULL is how you tell the database 'this field MUST have a value — you cannot leave it blank.