MicrolearnENPTES

UPDATE and DELETE

Lesson 23 of 24 · SQL.Micro

UPDATE changes existing rows and DELETE removes them. Both use WHERE to choose which rows; forget it and every row is affected.

UPDATE products SET price = price * 0.9 WHERE category = 'Books';

DELETE FROM orders WHERE status = 'cancelled';

Test the WHERE with a SELECT first, then run the UPDATE or DELETE.

Check yourself

What does DELETE FROM orders; do?

Give a 10% discount to every product in category 'Books' (new price = price × 0.9).

Do it in the browser: a real SQL tool, a short mission and instant feedback. No install.

Start this lesson — free
← INSERTIndexes and query plans →

All lessons · SQL.Micro