Lesson 4.10.4.1
4.10.4.1 Structured Query Language (SQL) Quiz: AQA Computer Science, Unit 10
20 questions
In partnership with Revision Ninja
Lesson 4.10.4.1, Structured Query Language (SQL): 20 multiple choice questions for the AQA Computer Science (7517), Unit 10: Fundamentals of databases, written with Revision Ninja.
Host it live on the board and students join with a game code on their own devices, or revise alone with Free Play. The answers are revealed in the game.
The 20 questions
-
Which SQL statement retrieves rows from a table?
- DELETE, which removes rows that match a condition from the table.
- UPDATE, which changes the values held in existing rows of the table, but which also adds any new rows that were not already present.
- INSERT, which adds new rows to the table being queried.
- SELECT, which reads rows matching the conditions given in the query.
-
Which SQL keyword adds a new row to a table?
- UPDATE, which changes values in rows that already exist in the table.
- INSERT INTO, which adds one or more rows with the values listed.
- SELECT, which returns existing rows and does not change the table at all.
- DROP TABLE, which removes the entire table and all of its rows.
-
Which statement changes existing values held in a table?
- UPDATE ... SET ... WHERE, which changes the named columns in the rows that match the condition.
- CREATE TABLE ..., which defines a brand new table with its columns and types.
- SELECT ... FROM ..., which returns rows and leaves the stored values unchanged.
- INSERT INTO ... VALUES, which adds new rows to the table with the given values.
-
Which clause limits which rows are affected by an UPDATE or DELETE statement?
- GROUP BY, which combines rows that share the same value into groups.
- HAVING, which applies a condition to groups after they have been formed.
- ORDER BY, which sorts the rows of the result into a chosen sequence.
- WHERE, which applies a condition that each row must satisfy.
-
What does this query return? SELECT Name FROM Customer WHERE City = 'York';
- The Name of every customer whose City is York.
- The City of every customer whose Name is York in the table.
- The number of customers in each city stored in the table being queried.
- Every column of each customer, sorted by the city in which they live.
-
Which statement creates a table Book with ISBN as a text primary key?
- MAKE TABLE Book WITH ISBN as key and Title as an attribute, stored in a new file that is then linked to the database by the server.
- CREATE TABLE Book (ISBN VARCHAR(13) PRIMARY KEY, Title VARCHAR(100));
- INSERT TABLE Book (ISBN VARCHAR(13), Title VARCHAR(100));
- CREATE Book TABLE (ISBN, Title) WITH PRIMARY KEY ISBN;
-
Which query adds a new student row to a Student table?
- UPDATE Student SET Name = 'Ada' WHERE StudentID = 101 and also adds a new row for 'Ada' if the student does not already exist in the table.
- SELECT Name FROM Student WHERE StudentID = 101;
- DELETE FROM Student WHERE StudentID = 101;
- INSERT INTO Student (StudentID, Name) VALUES (101, 'Ada');
-
Which statement removes only the students in Form 11X from a Student table?
- DELETE FROM Student;
- DELETE Student WHERE Form = '11X';
- REMOVE FROM Student WHERE Form = '11X'; which deletes the matching rows and also deletes the table definition from the database as well.
- DELETE FROM Student WHERE Form = '11X';
-
Which statement changes the price of product 7 to 4.50?
- UPDATE Product SET Price = 4.50 WHERE ProductID = 7;
- UPDATE Product WHERE ProductID = 7 SET Price = 4.50;
- UPDATE Price SET Product = 4.50 WHERE ProductID = 7;
- INSERT INTO Product SET Price = 4.50 WHERE ProductID = 7;
-
Which query lists each customer name together with the order IDs they placed, using a join?
- SELECT Name FROM Customer INNER JOIN Orders;
- SELECT Name, OrderID FROM Customer WHERE Orders.CustomerID = Customer.Name;
- SELECT Customer.Name, Orders.OrderID FROM Customer, Orders;
- SELECT Customer.Name, Orders.OrderID FROM Customer INNER JOIN Orders ON Customer.CustomerID = Orders.CustomerID;
-
Which query counts the number of orders placed by each customer?
- SELECT COUNT(CustomerID) FROM Customer GROUP BY OrderID;
- SELECT CustomerID, COUNT(*) FROM Orders GROUP BY CustomerID;
- SELECT CustomerID, AVG(*) FROM Orders GROUP BY CustomerID;
- SELECT CustomerID, COUNT(*) FROM Orders ORDER BY CustomerID; which gives one count for each customer.
-
Which query returns products priced above 10, sorted by price in descending order?
- SELECT * FROM Product WHERE Price > 10 GROUP BY Price DESC;
- SELECT * FROM Product HAVING Price > 10 SORT BY Price DESC;
- SELECT * FROM Product WHERE Price > 10 ORDER BY Price DESC;
- SELECT * FROM Product WHERE Price >= 10 ORDER BY Price ASC; which lists products priced at 10 or more, lowest first.
-
Which statement removes the whole table named OldStock, including its structure?
- DROP TABLE OldStock;
- REMOVE OldStock FROM DATABASE;
- DELETE TABLE OldStock;
- DELETE FROM OldStock;
-
Which SQL keyword combines rows from two tables where the keys match?
- DISTINCT, which removes duplicate rows from a single result set.
- UNION, which stacks the rows of two result sets into a single list.
- JOIN
- GROUP BY, which groups rows that share a value into a single summary row.
-
Which SQL clause sorts the rows of a query result?
- GROUP BY, which creates groups of rows that share a value.
- WHERE, which filters rows by a condition before they are returned.
- ORDER BY
- HAVING, which applies a condition to groups after they have been created.
-
Which query lists customers who have never placed an order?
- SELECT Name FROM Orders LEFT JOIN Customer ON Orders.CustomerID = Customer.CustomerID;
- SELECT Customer.Name FROM Customer LEFT JOIN Orders ON Customer.CustomerID = Orders.CustomerID WHERE Orders.OrderID IS NULL;
- SELECT Name FROM Customer INNER JOIN Orders ON Customer.CustomerID = Orders.CustomerID WHERE Orders.OrderID IS NULL; which lists customers with orders.
- SELECT Name FROM Customer WHERE CustomerID = NULL;
-
Which statement adds a foreign key in Orders that refers to the Customer table?
- ALTER TABLE Customer ADD FOREIGN KEY (Orders) REFERENCES CustomerID; which links each customer row to the order table.
- CREATE FOREIGN KEY Orders TO Customer;
- ALTER TABLE Orders SET PRIMARY KEY CustomerID;
- ALTER TABLE Orders ADD FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID);
-
A query uses SELECT DISTINCT City FROM Customer. What does it return?
- Each different city that appears in the Customer table, with duplicates removed.
- Every city in the table, including all of the duplicate entries that occur, listed in the order in which the rows were first inserted.
- Only the cities that have no customers recorded in them at all.
- The number of customers in each city, grouped by the name of the customer.
-
Evaluate: why is an UPDATE statement without a WHERE clause dangerous?
- It deletes the table before the update takes place, so all of its data is lost.
- It changes every row in the table, which is rarely intended and can cause widespread data loss.
- It is invalid SQL, so the statement fails with an error message and nothing in the table is ever changed, whatever the data holds.
- It changes only the first row in the table, which can leave the rest unchanged.
-
Which SQL test finds rows where a column has no value?
- = NULL, which compares the column with an empty string in each row.
- EQUALS EMPTY, which tests each column for a zero-length text value.
- NOT ZERO, which checks that the numeric column is never set to zero.
- IS NULL
Related quizzes
- Entity relationship modelling Quiz · 4.10.1.1 · 20 questions
- Relational databases Quiz · 4.10.2.1 · 20 questions
- Database design and normalisation Quiz · 4.10.3.1 · 20 questions
- Client server databases Quiz · 4.10.5.1 · 20 questions
- Data types Quiz · 4.1.1.1 · 20 questions
- Big Data Quiz · 4.11.1.1 · 20 questions
- Function types and first-class objects Quiz · 4.12.1.1 · 20 questions
- Analysis Quiz · 4.13.1.1 · 20 questions
- Data structures and abstract data types Quiz · 4.2.1.1 · 20 questions
- Breadth-first and depth-first search Quiz · 4.3.1.1 · 20 questions