wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL QUIZ

Total questions: 25

Worksheet time: 15mins

Name
Class
Date
1.

Which clause filters rows in SQL?

a)

SELECT

b)

FROM

c)

WHERE

d)

GROUP BY

2.

Which SQL command is used to retrieve data from a database?

a)

SELECT

b)

FROM

c)

WHERE

d)

GROUP BY

3.

Which of the following is NOT a string data type in MySQL?

a)

VARCHAR

b)

TEXT

c)

TIMESTAMP

d)

CHAR

4.

A floating point number can be defined using FLOAT or ______

a)

INT

b)

DOUBLE

c)

REAL

d)

NUMERIC

5.

Data Type that has FIXED length string (can contain letters, numbers, and special characters). The size parameter specifies the column length in characters - can be from 0 to 255. Default is 1

a)

BINARY(size)

b)

VARBINARY(size)

c)

CHAR(size)

d)

VARCHAR(size)

6.

Data Type considered as a medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is from 0 to 4294967295. The size parameter specifies the maximum display width (which is 255)

a)

SMALLINT(size)

b)

MEDIUMINT(size)

c)

INT(size)

d)

INTEGER(size)

7.

What does the SQL LEFT JOIN keyword do?

a)

Returns only matching records from both tables

b)

Returns all records from the left table and matching records form the right table

c)

Returns all records from the right table and matching records form the left table

d)

Returns all records from both tables

8.

With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"?

a)

SELECT * FROM Persons WHERE FirstName LIKE '%a'

b)

SELECT * FROM Persons WHERE FirstName = '%a%'

c)

SELECT * FROM Persons WHERE FirstName = 'a'

d)

SELECT * FROM Persons WHERE FirstName LIKE 'a%'

9.

How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?

a)

UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

b)

UPDATE Persons SET LastName='Hansen' WHERE LastName='Nilsen'

c)

UPDATE Persons SET LastName='Nilsen' WHERE LastName='Nilsen'

d)

UPDATE Persons SET LastName='Nilsen' WHERE LastName<>'Hansen'

10.

Which SQL statement uses the ANY operator correctly?

a)

SELECT * FROM Products WHERE ProductID ANY (SELECT ProductID FROM OrderDetails);

b)

SELECT * FROM Products WHERE ProductID = ANY (SELECT ProductID FROM OrderDetails);

c)

SELECT ProductName ANY (SELECT ProductID FROM OrderDetails WHERE Quantity > 10);

d)

SELECT * FROM Products WHERE ANY ProductID IN (SELECT ProductID FROM OrderDetails);

11.

Fill the blank in a query to find employees with no department assigned.

SELECT * FROM employees WHERE department_id IS (a)   ;

12.

Fill the blank in a query to find employees with salary greater than 8752.

SELECT * FROM (a)   WHERE salary > 8752;

13.

Fill the blank in a query to join employees and departments on department_id.

SELECT e.employee_id, e.name, d.department_name

FROM employees e

_____ ____ departments d ON e.department_id = d.department_id;

(a)  

14.

  • ______ _____ is used to create and retrieve data from the database very quickly



(a)  

15.

Fill in the The following SQL statement that adds an "Email" column to the "Customers" table:

(a)   TABLE Customers
ADD Email varchar(255);

16.

SQL Logical Operators that returns a value where operand matches a pattern

(a)  

17.

The SQL (a)   clause is used to filter the results of a GROUP BY query based on the result of an aggregate function. It is similar to the WHERE clause but is specifically applied after grouping and aggregation, allowing you to filter on the results of aggregate functions like COUNT, SUM, AVG, and others.

18.

Aggregate functions ignore null values (except for (a)   (*)).

19.

Write the correct SQL statement to create a new database called bookRef.

(a)  

20.

Write the correct SQL statement to drop a new database called bookArchive.

(a)  

21.

The NOT NULL constraint enforces a column to accept NULL values.

a)

TRUE

b)

FALSE

22.

The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true

a)

TRUE

b)

FALSE

23.

DATE data type correct format in SQL Server is YYYY-MM-DD

a)

TRUE

b)

FALSE

24.

A differential back up only backs up the parts of the database that have changed since the last full database backup.

a)

TRUE

b)

FALSE

25.

In MySQL, by default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record.

a)

TRUE

b)

FALSE