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 Structured Query Language
B Simple Question List
2. What is SQL mainly used for?
A Drawing pictures on a web page
B Asking a database for data
3. Which of these can SQL do to data in a database?
A Add, change and delete it
B Only look at it, never change it
4. Which statement is written correctly?
A SELECT * FROM students
B SELECT * FROM students;
5. What character ends an SQL statement?
A A semicolon ;
B A full stop .

Match the Pairs

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

Left columnRight column
1SELECT name FROM products; AThe statement has no semicolon at the end. Every SQL statement should finish with a semicolon (;).
2DELETE FROM orders WHERE orderId = 1; BUPDATE students SET points = 130 WHERE studentId = 1;
3SQL can add new data to a database CAn SQL statement that asks the database to show the name of every product
4SQL can change data that is already stored DThe second statement is missing its semicolon. Each statement needs its own semicolon at the end.
5SELECT firstName FROM students EAn SQL statement that removes one order record from the database
6SELECT * FROM students; SELECT * FROM results FINSERT INTO subjects VALUES (6, 'Art', 'Ms Cho');

Definitions

SQL

Fill in the Blanks

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

1.
______ firstName FROM students;
2.
______ FROM students WHERE studentId = 10;
3.
SELECT name, price ____ products;
4.
UPDATE students SET points = 130 WHERE _________ = 1;
5.
-- ___ stands for Structured Query Language SELECT * FROM students;

Spot the Error

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

Question 1
A SELECT firstName, points
B FORM students
C WHERE points > 100;
Question 2
A UPDATE products
B SET price = 5
C WHERE productId = 1;
D SELECT * FROM products
Question 3
A INSERT INTO students
B (studentId, firstName, house)
C VALUE (11, 'Zed', 'Red');
Question 4
A DELETE FROM orders
B WHERE quantity = 0;
C SELECT orderId, quantity
D FROM orders:
Question 5
A UPDATE students
B SET points == 150
C WHERE studentId = 1;

Answer Key

What SQL is
Section A: Quick Questions
Q1
A — Structured Query Language
Q2
B — Asking a database for data
Q3
A — Add, change and delete it
Q4
B — SELECT * FROM students;
Q5
A — A semicolon ;
Section B: Match the Pairs
Q1
SELECT name FROM products; → An SQL statement that asks the database to show the name of every product
Q2
DELETE FROM orders WHERE orderId = 1; → An SQL statement that removes one order record from the database
Q3
SQL can add new data to a database → INSERT INTO subjects VALUES (6, 'Art', 'Ms Cho');
Q4
SQL can change data that is already stored → UPDATE students SET points = 130 WHERE studentId = 1;
Q5
SELECT firstName FROM students → The statement has no semicolon at the end. Every SQL statement should finish with a semicolon (;).
Q6
SELECT * FROM students; SELECT * FROM results → The second statement is missing its semicolon. Each statement needs its own semicolon at the end.
Section C: Definitions
Q1
SQL — Structured Query Language: the standard language for asking a database for data, and for adding, changing or deleting it. Each statement ends with a semicolon.
Section D: Fill in the Blanks
Q1
SELECT firstName FROM students;
Q2
DELETE FROM students WHERE studentId = 10;
Q3
SELECT name, price FROM products;
Q4
UPDATE students SET points = 130 WHERE studentId = 1;
Q5
-- SQL stands for Structured Query Language SELECT * FROM students;
Section E: Spot the Error
Q1
B — The keyword is spelled wrong. SQL uses FROM to say which table to ask, so the line should be FROM students.
Q2
D — An SQL statement must end with a semicolon. It should be SELECT * FROM products;
Q3
C — The keyword is VALUES, with an S. It lists the data to add to the new record.
Q4
D — A statement ends with a semicolon, not a colon. It should be FROM orders;
Q5
B — SQL uses a single = to set a value. The line should be SET points = 150