wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL Review Quiz

Total questions: 79

Worksheet time: 40mins

Name
Class
Date
1.

Which clause can specify rows for aggregate functions?

a)

INSERT clause

b)

WHERE clause

c)

SELECT clause

d)

DELETE clause

2.

What do aggregate queries construct from a table?

a)

New tables

b)

New cells

c)

New columns

d)

New rows

3.

Which aggregate function is used to find the maximum value in a column?

a)

AVG(value)

b)

MIN(value)

c)

MAX(value)

d)

SUM(value)

4.

What SQL keyword is used to provide more meaningful names to result sets?

a)

ALIAS

b)

TITLE

c)

AS

d)

NAME

5.

Why might you use an ALIAS in a SQL query?

a)

To provide more meaningful names

b)

To make the query run faster

c)

To delete duplicate data

d)

To change the data type

6.

What is the primary use of the GROUP BY clause in SQL?

a)

To sort records

b)

To group records with the same values

c)

To delete records

d)

To filter records

7.

What is the purpose of using aliases in SQL queries?

a)

To rename columns or results

b)

To rename tables

c)

To join tables

d)

To delete data

8.

What does the following SQL query do: SELECT MIN(dateOrdered) FROM orders?

a)

Counts the number of dates in the dateOrdered column

b)

Finds the latest date in the dateOrdered column

c)

Finds the earliest date in the dateOrdered column

d)

Sums up all the dates in the dateOrdered column

9.

What does the AVG function do in SQL?

a)

Calculates the sum of values

b)

Finds the maximum value

c)

Finds the minimum value

d)

Calculates the average of values

10.

Which of the following SQL statements correctly uses the COUNT function to count all rows in a table called employees?

a)

SELECT COUNT(NULL) FROM employees;

b)

SELECT COUNT(DISTINCT employee_id) FROM employees;

c)

SELECT COUNT(*) FROM employees;

d)

SELECT COUNT(employee_id) FROM employees;

11.

Which of the following aggregate functions will return the highest value of a column named salary in a table named employees? (Select all that apply)

a)

SELECT MAX(salary) FROM employees;

b)

SELECT MIN(salary) FROM employees;

c)

SELECT AVG(salary) FROM employees;

d)

SELECT MAX(salary) AS highest_salary FROM employees;

12.

What is the result of the following SQL query? SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 5;

a)

Returns an error because HAVING cannot be used with COUNT(*).

b)

Returns the count of all departments with exactly 5 employees.

c)

Counts all employees in the database.

d)

Counts employees in each department and returns only departments with more than 5 employees.

13.

Which SQL statement correctly finds the average price of all products in the products table, excluding any rows where the price column is NULL?

a)

SELECT AVG(price) WHERE price IS NOT NULL FROM products;

b)

SELECT AVG(price) FROM products WHERE price IS NOT NULL;

c)

SELECT AVG(price) FROM products;

d)

SELECT AVG(price) FROM products WHERE price IS NULL;

14.

What does a table contain data about?

a)

A specific relation

b)

A specific entity type

c)

A specific key

d)

A specific attribute

15.

How is a table characterized?

a)

By nodes and edges

b)

By rows and columns

c)

By attributes and entities

d)

By keys and values

16.

What does a column in a relational model represent?

a)

A collection of tables

b)

A primary key

c)

A unique identifier for each row

d)

A specific attribute of the table's entity type

17.

What restricts the set of values allowed in a column?

a)

Foreign key

b)

Domain

c)

Index

d)

Primary key

18.

How are tables in a relational database linked to each other?

a)

By using foreign keys only

b)

Through relationships

c)

By using primary keys only

d)

By using indexes

19.

What is a potential issue with storing all information in a single table?

a)

It would require less maintenance

b)

It would contain duplicate data

c)

It would be easy to update

d)

It would be very efficient

20.

What is one consequence of redundancy in a database system?

a)

Reduced maintenance effort

b)

Slower system performance

c)

Easier data updates

d)

Faster system performance

21.

What is the first step in the normalization process?

a)

Achieving First Normal Form (1NF)

b)

Achieving Fourth Normal Form (4NF)

c)

Achieving Second Normal Form (2NF)

d)

Achieving Third Normal Form (3NF)

22.

What is the main goal of removing repeating groups in a database table?

a)

To allow data duplication

b)

To achieve first normal form

c)

To add more columns

d)

To create unnormalized tables

23.

What does the acronym DML stand for?

a)

a) Data Modeling Language

b)

b) Data Markup Language

c)

c) Data Management Language

d)

d) Data Manipulation Language

24.

Which SQL statement is used to add new rows to a table?

a)

a) CREATE

b)

b) DELETE

c)

c) UPDATE

d)

d) INSERT

25.

What happens if the number of columns listed in an INSERT statement does not match the number of values provided?

a)

a) The database will assign default values

b)

b) The values will be filled in randomly

c)

c) The extra columns will be ignored

d)

d) An error will occur

26.

Which SQL statement is used to change the data within an existing row?

a)

a) ALTER

b)

b) DELETE

c)

c) UPDATE

d)

d) INSERT

27.

In an INSERT INTO statement, which of the following is not a valid method of inserting rows?

a)

a) ALTER

b)

b) DELETE

c)

c) UPDATE

d)

d) INSERT

28.

Which of the following allows you to remove rows from a table in SQL?

a)

a) INSERT

b)

b) SELECT

c)

c) DELETE

d)

d) UPDATE

29.

What happens when you use the DELETE statement without a WHERE clause?

a)

All rows are deleted

b)

The command will produce an error

c)

Only the first row is deleted

d)

No rows are deleted

30.

Which command is used to remove all data from a table without removing the table itself?

a)

REMOVE

b)

TRUNCATE

c)

DROP

d)

DELETE

31.

In an UPDATE statement, what is the purpose of the WHERE clause?

a)

To sort the data before updating

b)

To limit the number of columns updated

c)

To check for foreign key constraints

d)

To specify which rows should be updated

32.

Which of the following SQL statements is not used to modify data in a table?

a)

SELECT

b)

INSERT

c)

UPDATE

d)

DELETE

33.

What happens if you try to insert a row with a foreign key that does not exist in the parent table?

a)

The row will be inserted with a NULL value for the foreign key

b)

The insertion will fail

c)

The insertion will succeed, but with a warning

d)

The row will be inserted, but the foreign key will be ignored

34.

Which operator can be used in an UPDATE statement to update records based on a pattern match?

a)

LIKE

b)

IN

c)

BETWEEN

d)

OR

35.

What SQL keyword is used to compare values in a range?

a)

IN

b)

LIMIT

c)

LIKE

d)

BETWEEN

36.

In the SQL statement UPDATE superheroes SET age = 37 WHERE age BETWEEN 35 AND 38;, which records will be updated?

a)

No records will be updated

b)

Only records with age 35 and 38

c)

All records with age 36

d)

Records with ages 35, 36, 37, and 38

37.

In the SQL statement DELETE FROM superheroes WHERE hero_id > 3;, what records will be deleted?

a)

No records will be deleted

b)

Records with hero_id greater than 3

c)

All records

d)

Only records with hero_id less than 3

38.

Which SQL keyword is used to specify the table from which to retrieve data?

a)

SELECT

b)

FROM

c)

JOIN

d)

WHERE

39.

What is the function of the SQL keyword 'SELECT'?

a)

To modify data

b)

To retrieve data

c)

To delete data

d)

To create a table

40.

What does the comparison operator '=' mean?

a)

Not equal to

b)

Equal to

c)

Greater than

d)

Less than

41.

Which operator means "greater than"?

a)

>=

b)

>

c)

<

d)

<=

42.

In the SQL query, which table is being queried? SELECT * FROM customers WHERE contactLastName < 'C';

a)

customers

b)

orders

c)

products

d)

employees

43.

Which of the following is a correct SQL statement to select all data from a table?

a)

SELECT DATA FROM table_name;

b)

SELECT * FROM table_name;

c)

SELECT COLUMNS FROM table_name;

d)

SELECT ALL FROM table_name;

44.

In SQL, what does the statement "SELECT * FROM customers" do?

a)

Deletes all data from the customers table

b)

Selects all columns from the customers table

c)

Selects specific columns from the customers table

d)

Updates all data in the customers table

45.

In the SQL query, what does the asterisk (*) represent?

a)

Select all columns

b)

Select all rows

c)

Select a specific column

d)

Select a specific row

46.

What is the function of the SQL statement: SELECT * FROM customers WHERE contactLastName LIKE '%sh'?

a)

Selects customers with last names starting with 'sh'

b)

Selects customers with last names exactly 'sh'

c)

Selects customers with last names containing 'sh'

d)

Selects customers with last names ending with 'sh'

47.

What is the result of using the OR condition with both conditions true?

a)

The record is deleted

b)

The record is not selected

c)

The record is selected

d)

The record is updated

48.

AND and OR both require all conditions to be true.

a)

AND and OR both require all conditions to be true

b)

AND requires both conditions to be true, OR requires at least one

c)

AND requires at least one condition to be true, OR requires both

d)

AND and OR both require at least one condition to be true

49.

What is the effect of the condition MSRP < 100 in a SQL query?

a)

It selects records with MSRP equal to 100.

b)

It selects records with MSRP not equal to 100.

c)

It selects records with MSRP greater than 100.

d)

It selects records with MSRP less than 100.

50.

What is the primary use of the IN condition in SQL?

a)

To delete records from a table

b)

To update records in a table

c)

To check if a value is within a specified list

d)

To sort records in a table

51.

What is the primary purpose of a relational database?

a)

To replicate data across tables

b)

To establish relationships between tables

c)

To increase redundancy

d)

To store data as plain text

52.

Which SQL command is used to create a table?

a)

INSERT

b)

DROP TABLE

c)

CREATE TABLE

d)

SELECT

53.

What does the AUTO_INCREMENT attribute do?

a)

Automatically increments a primary key value

b)

Automatically updates a row

c)

Automatically joins two tables

d)

Automatically creates a table

54.

Which join type retrieves only rows with matching conditions in both tables?

a)

INNER JOIN

b)

LEFT JOIN

c)

RIGHT JOIN

d)

FULL OUTER JOIN

55.

What is a Cartesian Product in SQL?

a)

The result of a SELECT query

b)

A type of indexing

c)

The combination of a LEFT and RIGHT JOIN

d)

The result of a JOIN without a WHERE clause

56.

What does a FOREIGN KEY in one table refer to?

a)

A secondary key in another table

b)

A primary key in another table

c)

An index in another database

d)

A column in the same table

57.

Which SQL clause specifies the condition for joining two tables?

a)

USING

b)

ON

c)

WHERE

d)

JOIN

58.

What is the purpose of table aliases in SQL?

a)

To rename tables permanently

b)

To delete tables

c)

To change table data types

d)

To temporarily assign alternate names to tables

59.

Which of the following does NOT return rows with NULL values in join conditions?

a)

RIGHT JOIN

b)

INNER JOIN

c)

LEFT JOIN

d)

FULL OUTER JOIN

60.

Which join includes all rows from the left table, even if there are no matches in the right table?

a)

RIGHT OUTER JOIN

b)

LEFT OUTER JOIN

c)

FULL OUTER JOIN

d)

INNER JOIN

61.

Which SQL query retrieves all rows from the product table?

a)

SELECT * FROM product;

b)

SELECT supplier FROM product;

c)

INSERT INTO product;

d)

SELECT * FROM supplier;

62.

What does the GROUP BY clause do in SQL?

a)

Filters rows

b)

Groups rows with the same values in specified columns

c)

Joins two tables

d)

Deletes duplicate rows

63.

What type of join is used to find rows that have no matching values in the other table?

a)

ANTI JOIN

b)

INNER JOIN

c)

CROSS JOIN

d)

FULL OUTER JOIN

64.

Which query lists the number of products each supplier provides?

a)

SELECT supplier, COUNT(*) FROM products;

b)

SELECT companyName, COUNT(productName) FROM suppliers;

c)

SELECT COUNT(supplier) FROM product;

d)

SELECT s.companyName, COUNT(p.productName) FROM suppliers AS s INNER JOIN products AS p ON s.SupplierID = p.SupplierID GROUP BY s.companyName;

65.

Which of the following are types of SQL joins?

a)

UNION

b)

CROSS JOIN

c)

OUTER JOIN

d)

INNER JOIN

66.

What are common issues with repeating data in databases?

a)

Inconsistent data updates

b)

Higher chances of errors

c)

Easier data retrieval

d)

Waste of storage space

67.

What actions can the WHERE clause perform in SQL?

a)

Exclude certain columns

b)

Sort data

c)

Specify join conditions

d)

Filter rows

68.

Which key is used to represent relationships between tables?

a)

Primary key

b)

Tertiary key

c)

Foreign key

d)

Secondary key

69.

What is the relationship between tables in a database called?

a)

Primary key relationship

b)

Unique key relationship

c)

Composite key relationship

d)

Foreign key relationship

70.

In the given SQL query, what is being selected? SELECT supplierID FROM products WHERE productName LIKE '%bread%';

a)

productName

b)

supplierID

c)

productID

d)

customerID

71.

What is the purpose of the '%' symbol in the SQL query? SELECT supplierID FROM products WHERE productName LIKE '%bread%';

a)

To represent a wildcard for any sequence of characters

b)

To denote a comment

c)

To indicate a table name

d)

To specify a column name

72.

What type of data is being queried in the example? SELECT * FROM suppliers

a)

Products

b)

Customers

c)

Suppliers

d)

Orders

73.

What would be the result if the 'LIKE' clause was changed to 'NOT LIKE' in the query? SELECT DISTINCT supplierID FROM products WHERE productName LIKE '%bread%';

a)

It would select products containing 'bread'

b)

It would select all products

c)

It would select products not containing 'bread'

d)

It would cause an error

74.

What does the SQL function MIN() return?

a)

The minimum value in a column

b)

The sum of values in a column

c)

The average value in a column

d)

The maximum value in a column

75.

What SQL clause is used to exclude certain values in a query?

a)

OMIT

b)

EXCLUDE

c)

NOT IN

d)

IN

76.

What does the SQL statement "SELECT * FROM products" do?

a)

Deletes all products

b)

Updates all products

c)

Selects specific columns from the products table

d)

Selects all columns from the products table

77.

What does the "NOT IN" clause do in the SQL query?

a)

Includes specified values

b)

Deletes specified values

c)

Updates specified values

d)

Excludes specified values

78.

What is a subquery in SQL?

a)

A command that retrieves the primary key of a table

b)

A standalone query unrelated to other queries

c)

A query embedded within another SQL query

d)

A filter that sorts data by date

79.

What is the purpose of a foreign key in relational databases?

a)

It uniquely identifies each row within a table

b)

It acts as a substitute for the primary key

c)

It is used only in subqueries

d)

It establishes a relationship between two tables