wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SQL Quiz

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.

Which SQL command is used to manage user permissions?

a)

Data Control Commands

b)

Data Definition Commands

c)

Data Manipulation Commands

d)

Aggregate Commands

2.

What is the purpose of aggregate functions in SQL?

a)

To perform calculations on a set of values and return a single value

b)

To define database structure

c)

To manage user permissions

d)

To execute triggers

3.

What is the purpose of nested queries in SQL?

a)

To use a query inside another query

b)

To define database structure

c)

To manage user permissions

d)

To perform string operations

4.

What is the purpose of domain constraints in SQL?

a)

To restrict the type of data that can be stored in a column

b)

To ensure relationships between tables remain consistent

c)

To define database structure

d)

To execute triggers

5.

What is the purpose of check constraints in SQL?

a)

To ensure that a column's value meets a specific condition

b)

To define database structure

c)

To manage user permissions

d)

To execute triggers

6.

What is the purpose of nested and complex queries in SQL?

a)

To perform advanced data retrieval operations

b)

To define database structure

c)

To manage user permissions

d)

To execute triggers

7.

What is the purpose of the "group by" clause in SQL?

a)

To organize data into groups based on a column

b)

To define database structure

c)

To manage user permissions

d)

To execute triggers

8.

What is the purpose of the "having" clause in SQL?

a)

To filter grouped data

b)

To define database structure

c)

To manage user permissions

d)

To execute triggers

9.

Which would find pupils with "er" anywhere in their name?

a)

SELECT * FROM Pupils Where Name = "%er"

b)

SELECT * FROM Pupils Where Name = "$er$"

c)

SELECT * FROM Pupils Where Name = "%er%"

d)

SELECT * FROM Pupils Where Name = "er%"

10.

What will be the output?

SELECT ROUND(36.7894,2)

a)

36.78

b)

38.79

c)

36.7

d)

36

11.

What will be the output?

SELECT TRUNCATE(36.5643,2);

a)

36.56

b)

36.57

c)

36.5643

d)

36

12.
Return all dramas made after 2004.
a)
SELECT * FROM movies WHERE genre = 'drama';
b)
SELECT * FROM movies WHERE genre = 'drama' AND year > 2004;
c)
SELECT * FROM movies WHERE genre = "drama' AND year < 2004;
d)
SELECT * FROM movies WHERE imdb_rating = 7 AND LIMIT = 7
13.


Which of the following SELECT query returns the department number with maximum salary compensated to an employee? (Consider the table structure as given)

a)

SELECT department_id , max(salary ) FROM employees ;

b)

SELECT department_id , max(salary ) FROM employees GROUP BY department_id ;

c)

SELECT max(salary ) FROM employees GROUP BY department_id ;

d)

SELECT max(salary ) FROM employees ;

14.

Predict the outcome of the below query

SELECT department_id ,avg(salary )
FROM employees 
HAVING avg(salary )>2000
GROUP BY department_id 
ORDER BY department_id 
a)

It executes successfully.

b)

It throws error because HAVING clause precedes the GROUP BY clause.

c)

It throws error because HAVING clause uses the aggregate function.

d)

It executes but no results are displayed because HAVING clause precedes the GROUP BY clause.

15.

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

a)

UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

b)

MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

c)

MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

d)

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

16.

With SQL how can I return all items in the Item table sorted from the lowest priced to the highest priced?

a)

SELECT * FROM Items ORDER BY Price ASCENDING

b)

SELECT * FROM Items ORDER BY Price ASC

c)

SELECT * FROM Items BY Price LOWEST TO HIGHEST

d)

SELECT * FROM Items ORDER BY Price DESC

17.

SQL query to find all the cities whose humidity is 95.

a)

SELECT city WHERE humidity = 95

b)

SELECT city FROM weather WHERE humidity = 95

c)

SELECT humidity = 89 FROM weather

d)

SELECT city FROM weather

18.

Which character returns all the data found in a table?

a)

%

b)

#

c)

*

d)

/

19.

You are required to update the phone number for only the DesignerID "SMI01" in the "Designer" table. Which of these would successfully do that?

a)

UPDATE Designer SET PhoneNo = '01224123456'

b)

UPDATE Designer (PhoneNo) VALUES ('01224123456')

c)

UPDATE Designer SET PhoneNo = '01224123456' WHERE DesignerID = 'SMI01'

d)

UPDATE PhoneNo = '01224123456' FROM Designer WHERE DesignerID = 'SMI01'

20.

Which SQL statement would add a record to the database?

a)

INSERT INTO Designer VALUES ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456')

b)

INSERT VALUES ('SMI01', 'M Smith', 'mail@msmith.com', 01224123456') INTO Designer

c)

INSERT ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456') INTO Designer

d)

INSERT Designer INTO VALUES (''SMI01', 'M Smith', 'mail@msmith.com', '01224123456')