What Is a Column Default? Distinguish Omitted Values, NULL, and Defaults
A column default is a value or expression the database supplies when an INSERT omits a column or explicitly requests DEFAULT. It does not validate data or repair existing rows. Omitting a column, writing NULL, and writing DEFAULT are different inputs.
What Is a Column Default? Distinguish Omitted Values, NULL, and Defaults
A column default is a value or expression the database supplies when an INSERT omits a column or explicitly requests DEFAULT. It does not validate data or repair existing rows. Omitting a column, writing NULL, and writing DEFAULT are different inputs.
When does a default apply?
If a column has a DEFAULT definition, an INSERT that leaves the column out uses that default. SQL can request it explicitly with the DEFAULT keyword too. Supplying NULL is different: a NOT NULL constraint rejects it; for a nullable column, NULL is stored instead of the default.
This PostgreSQL 18 example gives an order item default quantity and status:
CREATE TABLE order_items (
item_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
product_id bigint NOT NULL,
quantity integer NOT NULL DEFAULT 1,
status text NOT NULL DEFAULT 'pending',
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO order_items (product_id) VALUES (42)
RETURNING item_id, quantity, status, created_at;
INSERT INTO order_items (product_id, quantity, status)
VALUES (43, DEFAULT, DEFAULT)
RETURNING item_id, quantity, status;The first INSERT omits three columns, so the database supplies 1, pending, and CURRENT_TIMESTAMP. In PostgreSQL, CURRENT_TIMESTAMP means the start of the current transaction, not a separate wall-clock reading for each row. The SQL is illustrative and was not run.
Why are omission and NULL different?
A default answers “what should be supplied when no value was given?” Explicit NULL is a value choice in the SQL statement, not an omitted field. Thus, omitting quantity uses 1, while explicitly passing NULL violates NOT NULL. On a nullable column, explicit NULL remains NULL.
Applications should preserve the distinction between an absent request field (use the database default) and a field the caller intentionally clears (store NULL). If application code merges both cases, the default may never run.
Unspecified defaults vary by product. PostgreSQL treats a column with no declared default as having NULL as its default, so omitting a NOT NULL column with no default fails. MySQL 8.4 gives nullable columns an implicit NULL default; for NOT NULL columns without an explicit default, behavior can depend on SQL mode. Define needed defaults explicitly instead of relying on environment settings.
What can a default contain?
Defaults may be constants such as 1 or 'pending', or expressions/functions allowed by the DBMS. PostgreSQL evaluates a default expression when it is used, rather than when the table is created. Its CURRENT_TIMESTAMP is transaction-start time and remains stable within a transaction; other products may define “current time” differently.
A default does not validate later values. DEFAULT 1 does not ensure every quantity is positive. Use a suitable CHECK, NOT NULL, UNIQUE, or foreign-key constraint for rules that must always hold.
Does changing a default change old rows?
In PostgreSQL, ALTER COLUMN ... SET DEFAULT affects later INSERT or UPDATE commands; it does not rewrite existing rows. If historical data must change, plan a separate UPDATE and review its scope and operational impact. Adding a new column with a default has separate DDL behavior, so check the documentation for the target product and version.
Provider differences and practical checks
| Product | Example | Boundary |
|---|---|---|
| PostgreSQL 18 | quantity integer DEFAULT 1 | Omission and explicit DEFAULT use the default. An undeclared default is NULL; CURRENT_TIMESTAMP is transaction-start time. |
| SQL Server | quantity int CONSTRAINT DF_quantity DEFAULT (1) | A DEFAULT constraint supplies a value when none is provided; DEFAULT requests it. Without a default, a nullable column can receive NULL. |
| MySQL 8.4 | quantity INT NOT NULL DEFAULT 1 | Omission follows explicit/implicit defaults and SQL mode; strict mode may reject a missing value for a NOT NULL column with no default. |
Before troubleshooting, check the INSERT column list and whether it supplies NULL or DEFAULT; then verify DBMS, version, SQL mode, and nullability. Choose a business-meaningful default, use constraints for validation, and remember that changing a default alone does not migrate existing data.
Sources and scope
[PostgreSQL 18: Default Values](https://www.postgresql.org/docs/18/ddl-default.html)
[PostgreSQL 18: INSERT](https://www.postgresql.org/docs/18/sql-insert.html)
[PostgreSQL 18: ALTER TABLE](https://www.postgresql.org/docs/18/sql-altertable.html)
[PostgreSQL 18: Date/Time Functions](https://www.postgresql.org/docs/18/functions-datetime.html)
[Microsoft Learn: CREATE TABLE](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql?view=sql-server-ver17)
[Microsoft Learn: INSERT](https://learn.microsoft.com/en-us/sql/t-sql/statements/insert-transact-sql?view=sql-server-ver15)
[MySQL 8.4: INSERT](https://dev.mysql.com/doc/refman/8.4/en/insert.html)
[MySQL 8.4: Data Type Default Values](https://dev.mysql.com/doc/refman/8.4/en/data-type-defaults.html)
Official documentation checked 2026-11-23. SQL is an illustrative PostgreSQL 18 example and was not executed. Default, NULL, and SQL-mode behavior varies by product and version.