Example 1
Insert tasks without repeating the starting status
The first insert omits status, so the database stores the default value open. The second insert supplies blocked, which overrides the default for that row.
Source table data Rows loaded before the example query runs.
Setup
CREATE TABLE tasks (
id INT,
title VARCHAR(50),
status VARCHAR(20) DEFAULT 'open'
);Validated query Shared across supported engines.
SQL
INSERT INTO
tasks (id, title)
VALUES
(1, 'Review invoice');
INSERT INTO
tasks (id, title, status)
VALUES
(2, 'Ship order', 'blocked');
SELECT
id,
title,
status
FROM
tasks
ORDER BY
id;Expected result Returned rows for the shared example.
| id | title | status |
|---|---|---|
| 1 | Review invoice | open |
| 2 | Ship order | blocked |
Literal defaults behave the same way across supported engines in this example.