Skip to content

Default Value

Easy — everyone uses thisDatabase

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."

Made with passive-aggressive love by manoga.digital. Powered by Claude.