← VCE Spreadsheets, SQL & Visualisation

SQL UPDATE and DELETE

UPDATE changes field values and DELETE FROM removes records. Always add WHERE so only the chosen records change. Without it, every record in the table is changed or deleted.

Understanding SQL UPDATE and DELETE in VCE Spreadsheets, SQL & Visualisation

What it does: UPDATE with SET changes the email field, and WHERE id = 12 targets just one record. DELETE FROM without WHERE removes all records in the table. SQL does not guess which record you meant. Use WHERE with a unique value like a primary key so only the one booking is removed. The second statement wipes the whole table. The order matters: UPDATE, then SET, then WHERE. Putting WHERE before SET causes a syntax error.

Common mistakes: SQL uses a single = to give a field its new value in SET. The line should be SET year = 10. Text values must be in quotes. Without them, SQL treats sent as a field name. It should be SET status = 'sent'.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 55–70) and word search (Modules 55–86).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which statement changes Mia's grade to 'B' without affecting any other student?
UPDATE Students SET grade = 'B' WHERE name = 'Mia';UPDATE Students SET grade = 'B';
Matches
UPDATE Students SET year = 10;
↓
WHERE is missing, so every student's year is changed to 10. Add WHERE id = 7; to change just one record.
Applying
Meanings
Term
UPDATE table SET field = value WHERE condition;
Meaning
UPDATE changes field values and DELETE FROM removes records. Always add WHERE so only the chosen records change. Without it, every record in the table is changed or deleted.
Practice
UPDATE Students SET Year = 10 WHERE StudentID = 5;
Testing
Gaps
students SET year = 10 WHERE id = 3;
Check Answer
Spots
1UPDATE students
2SET year == 10

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Woodland Hedgehog' badge — Import Master, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which statement changes Mia's grade to 'B' without affecting any other student?
A. UPDATE Students SET grade = 'B' WHERE name = 'Mia'; ✓
B. UPDATE Students SET grade = 'B';
Without WHERE, the UPDATE changes the grade of every student in the table. WHERE limits the change to Mia's record.
2. What happens if you run DELETE FROM Orders; with no WHERE condition?
A. Every record in the Orders table is deleted ✓
B. Only the last record in the Orders table is deleted
DELETE FROM without WHERE removes all records in the table. SQL does not guess which record you meant.
3. Which keyword is used to change the value in a field of existing records?
A. CHANGE
B. UPDATE ✓
UPDATE with SET is the SQL way to change field values. CHANGE is not an SQL command for this.
4. Which statement correctly removes only the record with StudentID 12?
A. DELETE Students WHERE StudentID = 12;
B. DELETE FROM Students WHERE StudentID = 12; ✓
The correct form is DELETE FROM followed by the table name. The FROM keyword is required in this statement.
5. True or false: UPDATE Products SET price = 10; only changes one product.
A. False: it sets the price of every product to 10 ✓
B. True: UPDATE always changes just one record
UPDATE affects every record that matches its WHERE condition. With no WHERE, all records match, so all prices change.

Match the Pairs

UPDATE Students SET year = 10 WHERE id = 7; → Changes the year field to 10 for only the student whose id is 7
DELETE FROM Students WHERE id = 7; → Removes only the record for the student whose id is 7
Change a student's email address, but only for the student with id 12 → UPDATE Students SET email = 'sam@school.edu' WHERE id = 12;
Danger: leaving out WHERE deletes every record in the table → DELETE FROM Students;
UPDATE Students SET year = 10; → WHERE is missing, so every student's year is changed to 10. Add WHERE id = 7; to change just one record.
DELETE Students WHERE id = 7; → FROM is missing. The correct syntax is DELETE FROM Students WHERE id = 7;

Key Term

UPDATE table SET field = value WHERE condition;
UPDATE changes field values and DELETE FROM removes records. Always add WHERE so only the chosen records change. Without it, every record in the table is changed or deleted.

Fill in the Blanks

1. UPDATE students SET year = 10 WHERE id = 3;
Hint: Type the SQL keyword that changes values in existing records.
2. UPDATE students SET year = 10 WHERE id = 3;
Hint: Type the keyword that introduces the field and its new value.
3. DELETE FROM students WHERE id = 7;
Hint: Type the keyword that comes after DELETE and before the table name.
4. DELETE FROM students WHERE id = 7;
Hint: Type the keyword that limits which records are removed, so the whole table is not wiped.
5. UPDATE students SET year = 10 WHERE id = 3;
Hint: Type the comparison operator that picks the record with that exact id.

Spot the Error

Question 1
A UPDATE students
B SET year == 10
C WHERE id = 7;
Line B — SQL uses a single = to give a field its new value in SET. The line should be SET year = 10.
Question 2
A DELETE FROM orders
B WHERE id = 12;
C UPDATE orders
D SET status = sent
E WHERE id = 15;
Line D — Text values must be in quotes. Without them, SQL treats sent as a field name. It should be SET status = 'sent'.
Question 3
A UPDATE pets
B SET age = 4
C WHERE id = 2;
D DELETE FROM pets;
Line D — Leaving out WHERE deletes every record in the pets table. It should be DELETE FROM pets WHERE id = 9; so only one pet is removed.
Question 4
A UPDATE songs
B SET likes = 20
C WHEN title = 'Echo';
Line C — The keyword that picks which records to change is WHERE, not WHEN. It should be WHERE title = 'Echo';
Question 5
A -- remove used tickets
B DELETE tickets
C WHERE used = 1;
Line B — A DELETE statement needs the keyword FROM before the table name. It should be DELETE FROM tickets.

Student with a class code? Join your class →