James Gillespie's High School · Higher Computing Science 2026–27
Completed:
📁 File in OneNote: Higher Computing Science → Database Design & Development → DDD9
INSERT statement to add a new row to a table.UPDATE statement to change existing data.DELETE statement to remove rows, using WHERE correctly.Answer before the lesson begins — it's fine if you're unsure.
INSERT adds a new row to a table. Its basic form names the table, lists the columns being filled, and supplies matching values with VALUES:
INSERT INTO table (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);If every column in the table is being given a value, the column list can be left out entirely — but the values must then be supplied in exactly the same order the columns were defined in the table. Naming the columns explicitly is safer and clearer, and is the form used throughout this lesson.
A single INSERT statement can add several rows by listing multiple comma-separated value sets after VALUES:
INSERT INTO Instructor (instructorRef, firstName, surname, qualified)
VALUES
('INS05', 'Priya', 'Nair', True),
('INS06', 'Tom', 'Baxter', False);DDD8 already used UPDATE's syntax indirectly in its worked examples — this lesson makes it explicit. UPDATE changes the value of one or more fields in existing rows that match a WHERE condition:
UPDATE table
SET column1 = value1, column2 = value2, ...
WHERE condition;An UPDATE statement isn't limited to a single row — every row matching the WHERE condition is changed in one statement, which is exactly why the condition has to be precise.
DELETE removes entire rows from a table, using WHERE to select which ones:
DELETE FROM table
WHERE condition;Unlike UPDATE, DELETE doesn't specify individual columns — it removes the whole row, every field at once.
UPDATE and DELETE without a WHERE clause apply to every single row in the table, not just one. Running DELETE FROM Booking; with no WHERE deletes every booking the club has ever recorded, in one statement, with no confirmation prompt and no way to select the deleted rows back afterwards. This is the one part of SQL in this course with genuinely irreversible, real-data consequences — always write and check the WHERE clause before running an UPDATE or DELETE statement, never after.
INSERT INTO Member (memberID, firstName, surname, address, town, postcode, dateJoined)
VALUES ('M045', 'Aisha', 'Khan', '12 Marchmont Road', 'Edinburgh', 'EH9 1HA', '2026-07-11');SET the field to its new value, then use WHERE to target only that one class.WHERE clause, every class's fee would change to £7.50. See the statement below.UPDATE Class
SET feePerSession = 7.50
WHERE classCode = 'YOG01';WHERE — the safest possible criterion, since it can only ever match one row.DELETE FROM Booking
WHERE bookingRef = 'BKG045';A new instructor, Marcus Reid, joins the club — instructorRef 'INS04', qualified = True. Write the SQL to add his record.
INSERT INTO Instructor (instructorRef, firstName, surname, qualified)
VALUES ('INS04', 'Marcus', 'Reid', True);WHERE classCode = YOG01 is a syntax error; it must be WHERE classCode = 'YOG01'.When asked to describe, exemplify, and use INSERT, UPDATE, or DELETE, write the complete, working statement — full column list for INSERT, a correctly targeted WHERE clause for UPDATE and DELETE — rather than a fragment. An UPDATE or DELETE answer with no WHERE clause at all should be treated as incomplete, even if every other part is correct, since it changes the entire table rather than the intended record.
DELETE FROM Booking; is run with no WHERE clause?INSERT INTO Class (classCode, className, instructorRef, dayOfWeek, startTime, capacity, feePerSession)
VALUES ('SPN04', 'Spin 4', 'INS03', 'Thursday', '18:00', 20, 6.00);UPDATE Member
SET town = 'Musselburgh'
WHERE memberID = 'M012';DELETE FROM Booking WHERE attended = False;DELETE FROM Instructor
WHERE instructorRef = 'INS06';📁 File this in OneNote under:
Higher Computing Science → Database Design & Development → DDD9
Suggested timing: 8 min warm up · 15 min notes (INSERT/UPDATE/DELETE, why WHERE matters) · 15 min worked examples, ideally live in DataGrip on a disposable copy of the database · 5 min now you try · 20 min Task Set B · 5–10 min Task Set C / review, if time allows.
Sourcing note: this lesson's INSERT and DELETE syntax comes from the Heriot-Watt Scholar study guide (confirmed 11 Jul 2026) — neither the SQA spec's own Appendix 11 nor Chris Meechan's materials (slides or EOTT answer keys, all directly checked) demonstrate INSERT or DELETE syntax at all, despite the spec naming both as separately examinable. UPDATE is independently confirmed across all three sources. See ddd/DDD.md §3, §5, and §9 for the full cross-check.
Live demo strongly recommended, with a safety net: this is the one lesson where a live mistake genuinely damages the class's shared data. Demonstrate on a disposable copy of the database (or take a backup first), and consider deliberately running an UPDATE or DELETE with no WHERE clause live, on the disposable copy, so pupils see the consequence rather than just being told about it.
Quote-style note: both source materials for INSERT/DELETE (Scholar guide, Chris's materials) use double-quoted string literals, matching MS Access convention. This lesson deliberately uses single quotes throughout instead, staying consistent with DDD6–8's DataGrip/ANSI-SQL convention — not an inconsistency with the sources, a deliberate choice.
SQA command words covered: "describe", "exemplify", "use" (all three operations with working syntax), "read and explain code" (B5).