What SQL is

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

What SQL is

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does SQL stand for?
A Simple Question Locator
B Structured Query Language
2. Which SQL keyword asks a database to return data?
A SELECT
B DELETE
3. Which statement ADDS a new record to a table?
A INSERT INTO students VALUES (11, 'Sam');
B SELECT INTO students VALUES (11, 'Sam');
4. Which keyword changes data that is already stored in a table?
A SELECT
B UPDATE
5. Which statement is written in the standard SQL style, with keywords in capitals and a semicolon at the end?
A SELECT * FROM students;
B select * from students

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1SELECT firstName FROM students; AAsks the database to return the firstName of every student
2DELETE FROM students WHERE studentId = 3; BUPDATE students SET points = 130 WHERE studentId = 1;
3SQL can add a new row of data to a table CRemoves the student with studentId 3 from the table
4SQL can change data that is already stored, and each statement ends with a semicolon DINSERT INTO subjects VALUES (6, 'Art', 'Ms Ray');
5select firstName from students ESELECT is used to ask for data, not to add it; adding a row needs INSERT
6SELECT INTO students VALUES (11, 'Sam'); FThe statement has no semicolon at the end, and the keywords are not written in capitals as SQL style expects

Definitions

SQL

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
______ firstName, house FROM students;
2.
______ students SET points = 130 WHERE studentId = 1;
3.
______ FROM products WHERE stock = 0;
4.
SELECT name, teacher ____ subjects;
5.
INSERT ____ subjects VALUES (6, 'Art', 'Ms Ng');

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A SELECT firstName, house
B FROM students
C WHERE points > 100;
D DELETE results
E WHERE mark < 50;
Question 2
A GET firstName, points
B FROM students
C WHERE yearLevel = 7;
Question 3
A INSERT INTO subjects
B VALUE (6, 'Art', 'Ms Roy');
C SELECT * FROM subjects;
Question 4
A UPDATE students
B SET points = 130
C WHERE studentId = 1;
D SELECT firstName points
E FROM students;
Question 5
A SELCT name, price
B FROM products
C WHERE stock = 0;

Answer Key

What SQL is
Section A: Quick Questions
Q1
B — Structured Query Language
Q2
A — SELECT
Q3
A — INSERT INTO students VALUES (11, 'Sam');
Q4
B — UPDATE
Q5
A — SELECT * FROM students;
Section B: Match the Pairs
Q1
SELECT firstName FROM students; → Asks the database to return the firstName of every student
Q2
DELETE FROM students WHERE studentId = 3; → Removes the student with studentId 3 from the table
Q3
SQL can add a new row of data to a table → INSERT INTO subjects VALUES (6, 'Art', 'Ms Ray');
Q4
SQL can change data that is already stored, and each statement ends with a semicolon → UPDATE students SET points = 130 WHERE studentId = 1;
Q5
select firstName from students → The statement has no semicolon at the end, and the keywords are not written in capitals as SQL style expects
Q6
SELECT INTO students VALUES (11, 'Sam'); → SELECT is used to ask for data, not to add it; adding a row needs INSERT
Section C: Definitions
Q1
SQL — Structured Query Language, the standard language for asking a database to return data (SELECT) or to add, change or remove it (INSERT, UPDATE, DELETE).
Section D: Fill in the Blanks
Q1
SELECT firstName, house FROM students;
Q2
UPDATE students SET points = 130 WHERE studentId = 1;
Q3
DELETE FROM products WHERE stock = 0;
Q4
SELECT name, teacher FROM subjects;
Q5
INSERT INTO subjects VALUES (6, 'Art', 'Ms Ng');
Section E: Spot the Error
Q1
D — DELETE needs the keyword FROM before the table name. It should be DELETE FROM results.
Q2
A — SQL asks for data with the keyword SELECT. GET is not an SQL keyword. It should be SELECT firstName, points.
Q3
B — The keyword is spelled VALUES, with an S. INSERT INTO needs VALUES to add the new row.
Q4
D — Fields in a SELECT list must be separated by a comma. It should be SELECT firstName, points.
Q5
A — SELECT is misspelled. SQL keywords must be spelled exactly, so it should be SELECT name, price.