Computer Science Essentials, Unit 5, Lesson 3 of 4

Changing data and files

GCSE Computer Science, Databases and SQL, 25 minutes

Sign in

INSERT INTO, UPDATE and DELETE, then storing data in text and CSV files: open, read, write, append and close.

What you will learn

  • Work out the effect of INSERT, UPDATE and DELETE
  • Choose the right SQL command for a job
  • Choose read, write or append mode
  • Process records read from a CSV file

INSERT, UPDATE and DELETE

INSERT INTO Film (FilmID, Title, Genre, Year, Minutes)
VALUES (8, 'Iron Harbour', 'Action', 2023, 112)

UPDATE Film
SET Minutes = Minutes + 5
WHERE Genre = 'Musical'

DELETE FROM Film
WHERE Year < 2005
  • INSERT INTO adds one new record: one value for each field listed, in the same order, with text in quotes.
  • UPDATE changes the fields named after SET, in every record that meets WHERE.
  • DELETE FROM removes every record that meets WHERE.

Leave out WHERE and UPDATE changes every record, and DELETE empties the whole table.

Practise: INSERT, UPDATE and DELETE on Brainlag Code.

The rest of this lesson and its 18 practice questions are locked.

In this lesson

  1. INSERT, UPDATE and DELETE
  2. Text files and CSV files
  3. Try it: Before and after

18 practice questions, marked as you go; about 25 minutes in all.

Key terms

INSERT INTO, UPDATE, DELETE FROM, File, CSV

In this unit: Databases and SQL

Tables, records and fields, primary and foreign keys, why linked tables beat one big table, SQL queries over one or two tables, changing data with INSERT, UPDATE and DELETE, and reading and writing CSV files.

All of Databases and SQL