Module 55: SQL Fundamentals

Lesson 3 of 5 · 15–25 minutes

INSERT, UPDATE and DELETE

🏠The everyday picture

Adding a new line to the register, correcting a line, and striking a line out. The correction and the striking-out must be done on exactly the right line.

📘What it really is

INSERT INTO customers (name, phone, city)
VALUES ('Asha Kumari', '+919800000001', 'Patna'),
       ('Ravi Singh', '+919800000002', 'Gaya');
UPDATE customers
SET city = 'Muzaffarpur'
WHERE id = 7;
DELETE FROM customers WHERE id = 7;

🖱️Try it

Insert five courses in one statement. Update one course's fee, using a SELECT with the same WHERE first. Delete one course you inserted by mistake. Then, in a copy of your database, run an UPDATE without WHERE to see the damage.

✅Quick check

What does DELETE FROM customers; do?

Show the answer

Deletes every row in the table.

What's the safest way to write an UPDATE?

Show the answer

Run a SELECT with the same WHERE first to check exactly which rows will change.

← PreviousCreating and changing tables
ProLearners Assist