Lesson 10 of 12 · 10 min

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:

  1. Add a product: Tablet, category Electronics, price 300.
  2. Change the price of the Pen to 1.50.
  3. Delete the Monitor (nobody has ordered it).
query.sql
-- 1. Add the Tablet


-- 2. New price for the Pen


-- 3. Remove the Monitor

SQLite runs right here in your browser. The first run downloads about 0.7 MB; after that it is instant.

Discussion

Stuck? Ask here. Be kind, and share hints rather than full answers.

Loading the discussion…