wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PRE-TEST (SQL Filtering, Functions, and Grouping)

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.

Choose the letter of the correct answer. Which SQL constraint ensures that a column cannot have an empty value?

a)

UNIQUE

b)

CHECK

c)

NOT NULL

d)

PRIMARY KEY

2.

Choose the letter of the correct answer. What does NULL represent in SQL?

a)

Zero

b)

No value or unknown

c)

Blank space

d)

Empty string

3.

Choose the letter of the correct answer. Which operator is used to check if a column contains NULL?

a)

= NULL

b)

IS NULL

c)

== NULL

d)

HAS NULL

4.

Choose the letter of the correct answer. Which SQL clause is used to filter rows before grouping?

a)

HAVING

b)

WHERE

c)

GROUP BY

d)

ORDER BY

5.

Choose the letter of the correct answer. Which SQL clause is used to filter grouped results?

a)

WHERE

b)

ORDER BY

c)

HAVING

d)

DISTINCT

6.

Choose the letter of the correct answer. Which of the following is an aggregate function?

a)

CONCAT()

b)

ROUND()

c)

SUM()

d)

SUBSTR()

7.

Choose the letter of the correct answer. What does the GROUP BY clause do?

a)

Sorts results

b)

Arranges rows with the same values into groups

c)

Filters aggregated results

d)

Deletes duplicate rows

8.

Choose the letter of the correct answer. Identify the correct syntax for using GROUP BY:

a)

SELECT col FROM table HAVING col;

b)

SELECT col FROM table GROUP col;

c)

SELECT col, SUM(col) FROM table GROUP BY col;

d)

SELECT col WHERE col GROUP BY table;

9.

Choose the letter of the correct answer. Which command permanently saves changes made to a database?

a)

SAVE

b)

COMMIT

c)

APPLY

d)

UPDATE

10.

Choose the letter of the correct answer. Which command undoes unsaved changes?

a)

CANCEL

b)

ROLLBACK

c)

UNDO

d)

REVERT

11.

Choose the letter of the correct answer. Which statement is used to add a new column?

a)

ALTER TABLE ADD COLUMN

b)

UPDATE TABLE ADD

c)

MODIFY TABLE ADD

d)

CREATE TABLE ADD

12.

Choose the letter of the correct answer. Which SQL command modifies the datatype of an existing column?

a)

ALTER TABLE CHANGE

b)

ALTER TABLE MODIFY

c)

UPDATE COLUMN

d)

ALTER TABLE DATA

13.

Choose the letter of the correct answer. Which SQL command is used to rename a column?

a)

ALTER TABLE RENAME COLUMN

b)

ALTER TABLE CHANGE

c)

RENAME TABLE

d)

MODIFY COLUMN

14.

Choose the letter of the correct answer. A view in SQL is best described as:

a)

A physical table

b)

A backup file

c)

A saved SELECT query

d)

A temporary table

15.

Choose the letter of the correct answer. Which command is used to create a view?

a)

CREATE VIEW

b)

MAKE VIEW

c)

ADD VIEW

d)

INSERT VIEW

16.

Choose the letter of the correct answer. Which function returns the number of rows?

a)

SUM()

b)

COUNT()

c)

AVG()

d)

TOTAL()

17.

Choose the letter of the correct answer. Which function returns the average value?

a)

AVG()

b)

MEAN()

c)

COUNT()

d)

DIV()

18.

Choose the letter of the correct answer. Which is TRUE about FOREIGN KEY?

a)

It uniquely identifies each row in a table

b)

It references the primary key from another table

c)

It allows duplicate NULL values

d)

It deletes the referenced table automatically

19.

Choose the letter of the correct answer. What happens if you insert NULL into a NOT NULL column?

a)

The value is converted to zero

b)

It is allowed

c)

SQL returns an error

d)

The row is skipped

20.

Choose the letter of the correct answer. Which clause must be used with aggregate functions to group results?

a)

DISTINCT

b)

GROUP BY

c)

WHERE

d)

ORDER BY

21.

Write T if the statement is true and F if false: NULL is the same as zero in SQL.

a)

True

b)

False

22.

Write T if the statement is true and F if false: WHERE filters data before grouping.

a)

True

b)

False

23.

Write T if the statement is true and F if false: HAVING filters data after grouping.

a)

True

b)

False

24.

Write T if the statement is true and F if false: A view physically stores data in the database.

a)

True

b)

False

25.

Write T if the statement is true and F if false: COMMIT saves all changes permanently.

a)

True

b)

False

26.

Write T if the statement is true and F if false: ROLLBACK can undo changes even after COMMIT.

a)

True

b)

False

27.

Write T if the statement is true and F if false: ALTER TABLE can add and delete columns.

a)

True

b)

False

28.

Write T if the statement is true and F if false: COUNT(*) counts all rows, including NULL values.

a)

True

b)

False

29.

Write T if the statement is true and F if false: PRIMARY KEY columns can contain NULL values.

a)

True

b)

False

30.

Write T if the statement is true and F if false: GROUP BY is always required when using aggregate functions.

a)

True

b)

False