Level:
Correct: 0
Incorrect: 0
Marks: 0/0
Exam Practice
Course:
Topics:
AQA GCSE Computer Science (Paper 2) Smart practice A mixed round aimed at your weak spots
Unit 1
3.3 Fundamentals of data representation
Unit 2
3.4 Computer systems
Unit 3
3.5 Fundamentals of computer networks
Unit 4
3.6 Cyber security
Fundamentals of cyber security; cyber security threats
Cyber security, its threats and penetration testing
Methods to detect and prevent cyber security threats
Detecting and preventing cyber security threats
Unit 5
3.7 Relational databases and SQL
Unit 6
3.8 Ethical, legal and environmental impacts
Ethical, legal and environmental impacts
Ethical, legal and environmental impacts of technology
Avg
score:
–
Topics
done:
0/22

SQL: SELECT, INSERT, UPDATE and DELETE

Practise 35 exam-style questions on SQL: SELECT, INSERT, UPDATE and DELETE for AQA GCSE Computer Science (Paper 2). Write your answer as you would in the exam and get it marked in seconds against the mark scheme, point by point, with the Study Helper on hand if you get stuck.

  • 35 questions
  • 1–6 marks each
  • Instant marking
  • No sign-up needed
20 questions, marked as you go

Sample questions with model answers

Here are 4 of the questions in this topic, each with a model answer, an explanation of why it earns the marks and the mark scheme an examiner would use.

Question 1

1 mark

The table Ride, shown in the figure, stores details of the rides at a theme park. A query must list the rides with the lowest minimum height first.

Which clause should be used at the end of the query?

Choose your answer.

  • ORDER BY MinHeight DESC
  • ORDER BY MinHeight ASC
  • ORDER BY RideName ASC
  • WHERE MinHeight ASC
Table: Ride. Table with columns "RideID", "RideName", "Zone", "MinHeight", "WaitMins". RideID: R01; RideName: Tiger Trail; Zone: Jungle; MinHeight: 120; WaitMins: 45 | RideID: R02; RideName: Wave Rider; Zone: Coast; MinHeight: 110; WaitMins: 30 | RideID: R03; RideName: Canopy Drop; Zone: Jungle; MinHeight: 130; WaitMins: 55 | RideID: R04; RideName: Pirate Swing; Zone: Coast; MinHeight: 100; WaitMins: 20 | RideID: R05; RideName: Monkey Mayhem; Zone: Jungle; MinHeight: 90; WaitMins: 15 | RideID: R06; RideName: Lighthouse Leap; Zone: Coast; MinHeight: 120; WaitMins: 40 | RideID: R07; RideName: Sky Spinner; Zone: Skyline; MinHeight: 140; WaitMins: 60.

Model answer

ORDER BY MinHeight ASC

Explanation

ASC sorts from the smallest value to the largest, so Monkey Mayhem (90 cm) would be listed first and Sky Spinner (140 cm) last. DESC would put the highest minimum height first, ORDER BY RideName sorts alphabetically by name, and WHERE is used to filter records, not to sort them.

Mark scheme
  1. 1 mark

    ORDER BY MinHeight ASC

    Mark is for AO2 (apply). If more than one option is given, 0 marks.

Question 2

2 marks

A summer activity camp stores its sessions in the table Session, shown in the figure. This SQL is run:

DELETE FROM Session
WHERE Places < 6 OR Day = 'Friday'

State how many records are deleted and the SessionID of each record left in the table.

Table: Session. Table with columns "SessionID", "Activity", "Day", "Places", "Leader". SessionID: 1; Activity: Archery; Day: Monday; Places: 8; Leader: Mr Lowe | SessionID: 2; Activity: Kayaking; Day: Tuesday; Places: 4; Leader: Ms Ito | SessionID: 3; Activity: Climbing; Day: Wednesday; Places: 6; Leader: Mr Lowe | SessionID: 4; Activity: Orienteering; Day: Friday; Places: 12; Leader: Ms Ito | SessionID: 5; Activity: Raft building; Day: Thursday; Places: 5; Leader: Mr Dale | SessionID: 6; Activity: Bushcraft; Day: Friday; Places: 10; Leader: Mr Dale.

Model answer

4 records are deleted. The records left are SessionID 1 (Archery) and SessionID 3 (Climbing).

Explanation

With OR, a record is deleted if either condition is true: Kayaking (4 places) and Raft building (5 places) have fewer than 6 places, and Orienteering and Bushcraft are on a Friday. Climbing has exactly 6 places, which is not less than 6, so it stays along with Archery. Treating OR as AND is a common mistake - here it would delete nothing.

Mark scheme
  1. 1 mark

    4 records are deleted

    All marks AO2 (apply). R. 5 (Climbing has exactly 6 places, so it is not deleted).

  2. 1 mark

    SessionIDs 1 and 3 (Archery and Climbing) are left

    R. if any other SessionID is given as left.

Question 3

3 marks

The table Gig, shown in the figure, stores details of upcoming gigs. A new gig has been booked: GigID G7, the band Neon Harbour, at The Cellar on 23 January 2027 (stored as 2027-01-23), with 140 tickets available.

Write the SQL to add this gig to the table.

Table: Gig. Table with columns "GigID", "Band", "Venue", "GigDate", "Tickets". GigID: G1; Band: The Larks; Venue: Corn Exchange; GigDate: 2026-11-14; Tickets: 450 | GigID: G2; Band: Velvet Static; Venue: Town Hall; GigDate: 2026-11-28; Tickets: 300 | GigID: G3; Band: Neon Harbour; Venue: Corn Exchange; GigDate: 2026-12-05; Tickets: 520 | GigID: G4; Band: Paper Planes; Venue: The Cellar; GigDate: 2026-12-12; Tickets: 120 | GigID: G5; Band: The Larks; Venue: Town Hall; GigDate: 2026-12-19; Tickets: 350 | GigID: G6; Band: Moss and Stone; Venue: The Cellar; GigDate: 2027-01-09; Tickets: 150.

Model answer

INSERT INTO Gig (GigID, Band, Venue, GigDate, Tickets)
VALUES ('G7', 'Neon Harbour', 'The Cellar', '2027-01-23', 140)

Explanation

INSERT INTO names the table (and, optionally, the fields), and VALUES gives the data for the new record in brackets, in the same order as the fields. Text and dates need quotation marks, but the number of tickets does not. A common mistake is to use UPDATE, which only changes records that already exist.

Mark scheme
  1. 1 mark

    INSERT INTO Gig // INSERT INTO Gig (GigID, Band, Venue, GigDate, Tickets)

    All marks AO3 (program). Maximum 2 marks if any errors. I. Case / spacing. I. Semicolon at the end. A. Double quotation marks instead of single. DPT. Missing quotation marks around text values. DPT. Incorrect spelling of field or table names. DPT. == in place of =. (DPT: an error repeated in several places is penalised only once.) If a field list is given, the fields may be in any order but all five must be included.

  2. 1 mark

    VALUES

    R. VALUE.

  3. 1 mark

    ('G7', 'Neon Harbour', 'The Cellar', '2027-01-23', 140)

    The values must be in brackets and in the order of the field list if one is given, otherwise in the order of the fields in the table. A. the date in # signs. I. Quotation marks around 140.

Question 4

5 marks

A music venue company stores details of its gigs in the table Gig, shown in the figure. Dates are stored in the form YYYY-MM-DD.

Write an SQL query to show the band, venue and date of every gig in December 2026, in date order with the earliest gig first.

Table: Gig. Table with columns "GigID", "Band", "Venue", "GigDate", "Tickets". GigID: G1; Band: The Larks; Venue: Corn Exchange; GigDate: 2026-11-14; Tickets: 450 | GigID: G2; Band: Velvet Static; Venue: Town Hall; GigDate: 2026-11-28; Tickets: 300 | GigID: G3; Band: Neon Harbour; Venue: Corn Exchange; GigDate: 2026-12-05; Tickets: 520 | GigID: G4; Band: Paper Planes; Venue: The Cellar; GigDate: 2026-12-12; Tickets: 120 | GigID: G5; Band: The Larks; Venue: Town Hall; GigDate: 2026-12-19; Tickets: 350 | GigID: G6; Band: Moss and Stone; Venue: The Cellar; GigDate: 2027-01-09; Tickets: 150.

Model answer

SELECT Band, Venue, GigDate
FROM Gig
WHERE GigDate >= '2026-12-01' AND GigDate <= '2026-12-31'
ORDER BY GigDate ASC

Explanation

A gig is in December 2026 if its date is on or after 2026-12-01 and on or before 2026-12-31, so two conditions joined with AND are needed. Because the dates are written year first, they sort and compare correctly, and ORDER BY GigDate ASC puts the earliest gig first. The query returns the gigs on 5, 12 and 19 December: Neon Harbour, Paper Planes and The Larks.

Mark scheme
  1. 1 mark

    SELECT Band, Venue, GigDate

    All marks AO3 (program). Maximum 4 marks if any errors. Note to examiners: if more than one query is given, mark only the first. I. Case / spacing. I. Semicolon at the end. A. Double quotation marks instead of single. DPT. Missing quotation marks around text values. DPT. Incorrect spelling of field or table names. DPT. == in place of =. (DPT: an error repeated in several places is penalised only once.) A. the three fields in any order.

  2. 1 mark

    FROM Gig

  3. 1 mark

    One correct condition for the date range, e.g. GigDate >= '2026-12-01' // GigDate <= '2026-12-31'

    A. equivalent boundaries, e.g. GigDate > '2026-11-30' // GigDate < '2027-01-01'. A. dates in # signs or double quotation marks. A. GigDate BETWEEN '2026-12-01' AND '2026-12-31' for MS3 and MS4. A. GigDate LIKE '2026-12%' for MS3 and MS4.

  4. 1 mark

    Both date conditions correct and joined with AND

    R. OR in place of AND (every gig would be returned).

  5. 1 mark

    ORDER BY GigDate (ASC)

    I. Missing ASC. R. DESC.

Ready to try the rest? Every answer you write is marked against the mark scheme, so you can see exactly where the marks are.

Study Helper Hints first, answers after you try

Stuck on this one? Ask for a hint and I’ll point you in the right direction, without giving the answer away. Once you’ve checked your answer, I’ll show you how the marks are awarded.