Changing data
SELECT only reads. Three statements change data.
INSERT adds rows
INSERT INTO customers (name, city, joined)
VALUES ('Nyasha', 'Gweru', '2025-06-01');
List the columns, then the values in the same order. The id column is left out: SQLite gives a new row the next free id automatically.
UPDATE changes rows
UPDATE customers
SET city = 'Harare'
WHERE name = 'Kuda';
DELETE removes rows
DELETE FROM orders WHERE order_date < '2025-01-01';
The WHERE clause is your safety catch
UPDATE and DELETE without WHERE change or remove every row in the table. Professionals often write the WHERE first, and test it with a SELECT before turning it into an UPDATE.
Each run here starts from a fresh copy of the shop, so you cannot break anything.
Your task
Write three statements:
- Add a product:
Tablet, categoryElectronics, price300. - Change the price of the
Pento1.50. - Delete the
Monitor(nobody has ordered it).