Day 21 10 min
Changing data
1 / 12 · ≈ 8 min left
The problem
You look after the database of a small online shop. Checkout lowers the stock as orders come in, and a supplier sends a product file every night. Today the import failed halfway, so you fix the rows by hand in psql. Each statement must touch only the rows you name.
The database is PostgreSQL. The table is products (sku text PRIMARY KEY, price numeric(8,2) NOT NULL, stock int NOT NULL DEFAULT 0). It holds 3 rows: MUG-01 at 12.00 with stock 40, TEE-02 at 20.00 with stock 15, and CAP-03 at 15.00 with stock 0. Each rep starts from these 3 rows.