INSERT, UPDATE, DELETE
A new order lands in the orders table, and correcting the amount on row id = 104 leaves the other three alone. Forget to name the row, and every order changes, with only one number to warn you.
- ▸A row missing a column gets its default or NULL, but leaving out a required column like
idfails. - ▸Forget to say which rows, and a write changes all of them or empties the table outright.
- ▸The number reported back, rows added, matched, or removed, is the blast radius: zero matched nothing, four hit everything.
The orders table holds four rows, one per order placed so far: 101, 102, 103, 104. A fifth order comes in, so you append it: INSERT INTO orders (id, user_id, amount, created_at) VALUES (105, 2, 25.00, '2026-02-14'). The table now holds five rows, and the four already there are untouched. On success the database answers with a count, INSERT 0 1, telling you one row landed (the last number is the count; the 0 is a leftover slot PostgreSQL always fills with 0).
You do not have to fill every column. List only the ones you have, INSERT INTO orders (id, user_id) VALUES (106, 3), and the columns you left out, amount and created_at, take their default value, or NULL when the column has no default. Order 106 lands with a blank amount, the same NULL marker a missing value always carries.
One statement can add several rows at once: stack the value lists, VALUES (107, 1, 12.00, '2026-02-15'), (108, 2, 8.00, '2026-02-16'), and the count comes back INSERT 0 2. The rows append in a single shot, and the count is your confirmation of how many.