Data Changes
Update Rows
Changing Existing Data
UPDATE changes columns in rows that match a condition.
Program
Play the script to mark one item as stocked.
update_rows.sql
CREATE TABLE inventory (sku TEXT, stock INTEGER);
INSERT INTO inventory VALUES ('pen', 0), ('book', 3);
UPDATE inventory SET stock = 5 WHERE sku = 'pen';
SELECT * FROM inventory ORDER BY sku;
UPDATE
`UPDATE inventory SET stock = 5` changes a column.
WHERE
The `WHERE` clause limits which rows change.
state change
The table snapshot shows before and after state.