wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL Basics MCQ Worksheet (Digitized)

Total questions: 83

Worksheet time: 47mins

Name
Class
Date
1.

What does SQL stand for?

a)

Simple Query Language

b)

Standard Query Logic

c)

Structured Query Language

d)

System Query Link

2.

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

a)

EXTRACT

b)

GET

c)

SELECT

d)

RETRIEVE

3.

Which SQL command is used to update existing data in a database?

a)

MODIFY

b)

UPDATE

c)

ALTER

d)

REVISE

4.

Which SQL command is used to create a new table in a database?

a)

NEW TABLE

b)

INSERT TABLE

c)

MAKE TABLE

d)

CREATE TABLE

5.

Which clause is used in the CREATE TABLE statement to uniquely identify each record?

a)

FOREIGN KEY

b)

UNIQUE

c)

PRIMARY KEY

d)

NOT NULL

6.

Which SQL command is used to add new records to a table?

a)

INSERT NEW

b)

ADD RECORD

c)

INSERT INTO

d)

CREATE RECORD

7.

Which type of command does CREATE TABLE fall under?

a)

DQL (Data Query Language)

b)

DML (Data Manipulation Language)

c)

DDL (Data Definition Language)

d)

TCL (Transaction Control Language)

8.

The statement SELECT * FROM tbl_Employee; retrieves:

a)

Only the first row of data.

b)

All columns and all rows from the table.

c)

Only the primary key column.

d)

Distinct values from the table.

9.

Which keyword is used to return only distinct (different) values in a result-set?

a)

UNIQUE

b)

DIFFERENT

c)

ALL

d)

DISTINCT

10.

Which clause is used to filter records in a SELECT statement?

a)

FILTER BY

b)

WHERE

c)

CONDITION

d)

SELECT IF

11.

Which operator is used for pattern matching in SQL?

a)

EQUALS

b)

MATCHES

c)

LIKE

d)

CONTAINS

12.

What is the correct syntax to delete records from tbl_Student where SProvince is 'Bukidnon'?

a)

DELETE SProvince='Bukidnon' FROM tbl_Student;

b)

REMOVE FROM tbl_Student WHERE SProvince='Bukidnon';

c)

DELETE FROM tbl_Student WHERE SProvince='Bukidnon';

d)

REMOVE tbl_Student WHERE SProvince='Bukidnon';

13.

What will UPDATE tbl_Employee SET Salary = 70000.00 WHERE EmployeeID = 1001; do?

a)

Update the EmployeeID to 1001.

b)

Insert a new record with a Salary of 70000.00.

c)

Change the Salary to 70000.00 for the employee with EmployeeID 1001.

d)

Change all salaries to 70000.00.

14.

To retrieve the LName and City columns from tbl_Employee, the correct syntax is:

a)

SELECT LName, City IN tbl_Employee;

b)

SELECT LName AND City FROM tbl_Employee;

c)

SELECT LName, City FROM tbl_Employee;

d)

GET LName, City FROM tbl_Employee;

15.

If you omit the WHERE clause in an UPDATE statement, what happens?

a)

No records are updated.

b)

An error is generated.

c)

The first record is updated.

d)

All records in the table are updated.

16.

The WHERE clause is typically used with which SQL commands?

a)

SELECT and CREATE TABLE

b)

SELECT, UPDATE, and DELETE

c)

INSERT INTO and SELECT

d)

ALTER TABLE and DROP TABLE

17.

Which keyword is used to sort the result-set in SQL?

a)

SORT BY

b)

ARRANGE BY

c)

GROUP BY

d)

ORDER BY

18.

By default, how does the ORDER BY clause sort the results?

a)

Randomly

b)

Descending (DESC)

c)

Ascending (ASC)

d)

By Primary Key

19.

Which keyword is used to sort the result-set from highest to lowest value?

a)

ASC

b)

DESC

c)

HIGH

d)

LOW

20.

Which logical operator is used to display a record if both of the conditions are TRUE?

a)

OR

b)

NOT

c)

AND

d)

EITHER

21.

Which logical operator is used to display a record if at least one of the conditions is TRUE?

a)

OR

b)

EITHER

c)

NOT

d)

AND

22.

Which logical operator negates a condition (i.e., returns records that do not satisfy the condition)?

a)

NOT

b)

NONE

c)

NEITHER

d)

EXCLUDE

23.

Which operator selects between two values?

a)

IN

b)

RANGE

c)

BETWEEN

d)

LIKE

24.

The SQL query fragment WHERE price IS NULL is used to:

a)

Find records where the price is zero.

b)

Find records where the price column has no assigned value.

c)

Find records where the price is not a number.

d)

Find records where the price has been deleted.

25.

Which SQL function calculates the number of rows in a result set?

a)

COUNT

b)

SUM

c)

NUMBER

d)

LENGTH

26.

Which SQL function calculates the average value of a numeric column?

a)

MEAN

b)

AVG

c)

SUM / COUNT

d)

CALCULATE

27.

The SQL function MAX() is used to find the:

a)

Largest value in the specified column.

b)

Total sum of the column.

c)

Smallest value in the specified column.

d)

The product with the highest quantity.

28.

Which clause is used to group rows that have the same values in specified columns into summary rows?

a)

ORDER BY

b)

GROUP BY

c)

SUM BY

d)

HAVING

29.

Which clause is used to filter the results of an aggregate function (i.e., filtering groups)?

a)

WHERE

b)

FILTER

c)

GROUP WHERE

d)

HAVING

30.

What is the result of the SQL expression (Quantity * Price) in a SELECT statement?

a)

and Price.

b)

Price.

c)

Quantity and Price for each row.

d)

An alias for the result of COUNT(product_id) function.

31.

In the query SELECT Category, COUNT(product_id) AS product_count..., what does product_count represent?

a)

A column in the products table.

b)

An alias for the Category column.

c)

The total number of products across all categories.

d)

An alias for the result of the COUNT(product_id) function.

32.

When should you use HAVING instead of WHERE?

a)

When filtering based on a non-aggregated column.

b)

They are interchangeable and can be used for any filter.

c)

When filtering based on the result of an aggregate function.

d)

HAVING is a legacy command and should not be used.

33.

What is the correct way to calculate a column alias called MonthlySalary as Salary divided by Months?

a)

SELECT Salary / Months AS MonthlySalary

b)

SELECT Salary, Months / MonthlySalary

c)

SELECT (Salary / Months) = MonthlySalary

d)

SELECT MonthlySalary = Salary / Months

34.

What is the primary purpose of the SQL UNION clause?

a)

To sort the data from

b)

To combine rows from

c)

To insert new data into

d)

To create a new

35.

What is the purpose of the JOIN clause in SQL?

a)

to combine rows from two or more tables based on a related column.

b)

to retrieve data from multiple tables simultaneously.

c)

to filter records from two existing tables.

36.

Which type of join returns only the rows that have matching values in both tables?

a)

LEFT JOIN

b)

RIGHT JOIN

c)

INNER JOIN

37.

Which type of join returns all records from the left table, and the matched records from the right table, with NULL for the right side if there is no match?

a)

RIGHT JOIN

b)

LEFT JOIN

c)

INNER JOIN

38.

What is the primary goal of database normalization?

a)

To eliminate data redundancy and anomalies.

b)

To increase the speed of query execution.

c)

To ensure all tables have the same number of columns.

39.

What is SQL?

a)

A relational database management system

b)

A programming language for web development

c)

A programming language for storing and processing information in a relational database

d)

A tool for graphical database design

40.

Where is data stored in SQL?

a)

Files

b)

Tables

c)

Arrays

d)

Objects

41.

What does the CREATE DATABASE statement do?

a)

Deletes a database

b)

Creates a new SQL database

c)

Modifies a database

d)

Displays the structure of a database

42.

What keyword is used to sort data in SQL?

a)

GROUP BY

b)

SORT

c)

FILTER

d)

ORDER BY

43.

What is an algorithm?

a)

A type of database

b)

A programming language

c)

A type of data model

d)

A sequence of instructions for solving a problem

44.

Why are primary keys important in databases?

a)

To store large amounts of data

b)

To uniquely identify each entity

c)

To sort data

d)

To create relationships between databases

45.

What is the purpose of the SELECT statement?

a)

To delete records

b)

To insert records

c)

To select data from a database

d)

To update existing records

46.

How does the NOT operator work in SQL?

a)

It includes all conditions that are true

b)

It excludes records matching the specified conditions

c)

It sorts data in descending order

d)

It combines multiple conditions

47.

When should you use INNER JOIN?

a)

When combining records with matching values in both tables

b)

When including all records from the left table

c)

When including all records from the right table

d)

When including all records from both tables

48.

What does the COUNT() function return?

a)

The total sum of numeric values

b)

The average of numeric values

c)

The number of rows matching a specified criterion

d)

The maximum value in a column

49.

What would be the result of SELECT * FROM Customers?

a)

Deletes all customers from the database

b)

Updates customer records

c)

Selects all columns and rows from the Customers table

d)

Counts the total number of customers

50.

How would you insert a new record into a table?

a)

Use the SELECT INTO statement

b)

Use the INSERT INTO statement

c)

Use the UPDATE statement

d)

Use the DELETE statement

51.

What happens when you use LEFT JOIN?

a)

Only matching records are returned

b)

All records from the right table are returned, and matching records from the left table

c)

All records from both tables are returned

d)

All records from the left table are returned, and matching records from the right table

52.

How do you compute the total price in a table?

a)

Use the AVG() function

b)

Use the SUM() function

c)

Use the COUNT() function

d)

Use the MAX() function

53.

Which SQL statement modifies existing records?

a)

DELETE

b)

INSERT INTO

c)

UPDATE

d)

SELECT

54.

Why might a composite attribute be subdivided into smaller parts?

a)

To better represent its constituent data elements

b)

To simplify storage requirements

c)

To reduce redundancy

d)

To create relationships between tables

55.

How do ER diagrams help in database design?

a)

They provide a graphical representation of data relationships

b)

They execute queries

c)

They optimize database performance

d)

They store records

56.

When is a FULL OUTER JOIN appropriate?

a)

To return only matching records between two tables

b)

To return all records from both tables regardless of matching

c)

To exclude records without matches

d)

To return records from one table only

57.

What does a derived attribute indicate?

a)

A primary key attribute

b)

An attribute with multiple values

c)

A value calculated from other attribute values

d)

An attribute unrelated to other data

58.

How does the WHERE clause refine SQL queries?

a)

By grouping data

b)

By defining the conditions for data selection

c)

By limiting the number of returned rows

d)

By ordering results alphabetically

59.

Why should databases avoid redundancy?

a)

To minimize storage costs and improve data integrity

b)

To enhance readability

c)

To simplify data retrieval

d)

To make databases easier to understand

60.

How do you determine the most efficient join for a query?

a)

By examining the tables’ attributes and relationships

b)

By always using INNER JOIN

c)

By testing each join type

d)

By using trial-and-error

61.

Which condition is better for filtering rows: WHERE or HAVING?

a)

HAVING should always be used

b)

To minimize storage costs and improve data integrity

c)

Both can be used interchangeably

d)

WHERE for numeric columns, HAVING for text columns

62.

What is the impact of using NULL values in joins?

a)

It creates an error

b)

It guarantees better performance

c)

It excludes certain rows unless handled explicitly

d)

It automatically matches all rows

63.

When is the CASE expression useful?

a)

For modifying existing data

b)

For creating new tables

c)

For updating database schemas

d)

For applying conditional logic in a query

64.

Design a query to display the product names and their suppliers from two tables.

a)

Use SELECT and INNER JOIN

b)

Use INSERT INTO

c)

Use DELETE and DROP

d)

Use CASE and HAVING

65.

How would you structure a query to calculate the average price of dairy products?

a)

Use SELECT and GROUP BY

b)

Use AVG() with a WHERE condition for category

c)

Use SUM() and COUNT()

d)

Use MAX() for the price column

66.

When creating a table, how do you define its schema?

a)

By specifying columns and their data types

b)

By importing data

c)

By writing SELECT statements

d)

By executing DROP statements

67.

What steps are necessary for writing a join between PRODUCTS and SUPPLIERS?

a)

Identify foreign keys and use the JOIN statement

b)

Use SELECT * without conditions

c)

Update both tables beforehand

d)

Use only LEFT JOIN

68.

How can you create a normalized database schema?

a)

By creating tables without relationships

b)

By reducing redundancy and ensuring data dependencies

c)

By avoiding primary keys

d)

By using a single table for all data

69.

The DDL command used to completely remove a table and all its data from the database.

(a)  

70.

The clause used in a SELECT statement to filter records, extracting only those that fulfill a specified condition.

(a)  

71.

The standard of the American National Standards Institute (ANSI) that SQL became in 1986.

(a)  

72.

The SQL command used to add new rows (records) into an existing table.

(a)  

73.

The type of join that returns only the rows that have matching values in both the left and right tables.

(a)  

74.

A table is in this Normal Form when it is in 1NF, and all non-key attributes are fully dependent on the entire primary key (eliminating partial dependencies).

(a)  

75.

The step of normalization addresses no repeating groups (i.e., multiple columns storing the same type of data, or multiple values in one cell)

(a)  

76.

It occurs when a non-key attribute is dependent on another non-key attribute, which in turn depends on the primary key (Key → Non-Key A → Non-Key B).

(a)  

77.

The database contains two tables: Employees and Departments. To retrieve a result set that includes only employees who have an assigned department and only departments that have at least one employee, which SQL query is correct?

a)

SELECT * FROM Employees INNER JOIN Departments ON Employees.DeptID = Departments.DeptID;

b)

SELECT * FROM Employees FULL OUTER JOIN Departments ON Employees.DeptID = Departments.DeptID;

c)

SELECT * FROM Employees LEFT JOIN Departments ON Employees.DeptID = Departments.DeptID;

d)

SELECT * FROM Employees CROSS JOIN Departments;

78.

You need to generate a report showing all employees and their respective department names. Employees who have not yet been assigned a department must still appear in the report, with a NULL value for the department name. Which join is appropriate?

a)

SELECT * FROM Employees FULL OUTER JOIN Departments ON Employees.DeptID = Departments.DeptID;

b)

SELECT * FROM Employees LEFT JOIN Departments ON Employees.DeptID = Departments.DeptID;

c)

SELECT * FROM Employees INNER JOIN Departments ON Employees.DeptID = Departments.DeptID;

d)

SELECT * FROM Employees RIGHT JOIN Departments ON Employees.DeptID = Departments.DeptID;

79.

A table named Projects contains a ProjectLeadID (a foreign key referencing Employees.EmployeeID). Which query correctly returns a list of all employees and the details of any projects they lead, including employees who lead no projects?

a)

SELECT * FROM Employees, Projects WHERE Employees.EmployeeID = Projects.ProjectLeadID;

b)

SELECT * FROM Employees LEFT JOIN Projects ON Employees.EmployeeID = Projects.ProjectLeadID;

c)

SELECT * FROM Employees INNER JOIN Projects ON Employees.EmployeeID = Projects.ProjectLeadID;

d)

SELECT * FROM Employees RIGHT JOIN Projects ON Employees.EmployeeID = Projects.ProjectLeadID;

80.

Which of the following SQL CASE expressions correctly categorizes prices from a Products table into 'High' (price> 100), 'Medium' (price between 50 and 100), or 'Low' (price <= 50)?

a)

SELECT ProductName, CASE WHEN Price > 100 THEN 'High' WHEN Price BETWEEN 50 AND 100 THEN 'Medium' ELSE 'Low' END AS PriceCategory FROM Products;

b)

SELECT ProductName, CATEGORIZE(Price, 'High', 'Medium', 'Low') FROM Products;

c)

SELECT ProductName, CASE Price WHEN > 100 THEN 'High' WHEN 50 TO 100 THEN 'Medium' ELSE 'Low' END AS PriceCategory FROM Products;

d)

SELECT ProductName, CASE WHEN Price > 100 THEN 'High' ELSE 'Medium' WHEN Price <= 50 THEN 'Low' END AS PriceCategory FROM Products;

81.

In a Customers table, if the Country column is NULL, the report should display 'Unknown'. If the Country is 'USA', it should display 'Domestic'. For all other countries, it should display 'International'. Which of the following correctly handles the NULL value?

a)

CASE WHEN Country = NULL THEN 'Unknown' WHEN Country = 'USA' THEN 'Domestic' ELSE 'International' END

b)

CASE WHEN Country = 'USA' THEN 'Domestic' WHEN Country IS NULL THEN 'Unknown' ELSE 'International' END

c)

CASE Country WHEN NULL THEN 'Unknown' WHEN 'USA' THEN 'Domestic' ELSE 'International' END

d)

CASE WHEN Country IS NULL THEN 'Unknown' WHEN Country = 'USA' THEN 'Domestic' ELSE 'International' END

82.

You are using the 'simple' CASE expression to check the value of the Status column. Which of the following code snippets correctly uses the 'simple' CASE expression structure?

a)

CASE (Status) AS StatusCheck WHEN 'Active' THEN 1 ELSE 0 END

b)

CASE Status WHEN 'Active' THEN 1 WHEN 'Inactive' THEN 0 ELSE 0 END

c)

CASE WHEN Status = 'Active' THEN 1 WHEN Status = 'Inactive' THEN 0 END

d)

CASE 'Active' THEN 1 ELSE 0 WHEN 'Inactive' THEN 0 END

83.

The primary role of the ELSE clause in a SQL CASE expression is to:

a)

Handle any syntax errors that occur during the evaluation of the WHEN clauses.

b)

Provide an optional condition to execute a subquery if the CASE expression is computationally expensive.

c)

Specify the condition that must be met if all preceding WHEN conditions are false.

d)

Define a default return value for the expression if none of the preceding WHEN conditions are satisfied.