wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SQL Mastery Challenge

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

What is the purpose of a JOIN in SQL?

a)

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

b)

To create a new table in the database.

c)

To update existing records in a table.

d)

To delete rows from a table.

2.

Explain the difference between INNER JOIN and LEFT JOIN.

a)

INNER JOIN returns matching rows from both tables; LEFT JOIN returns all rows from the left table and matched rows from the right table.

b)

INNER JOIN and LEFT JOIN are identical in functionality and output.

c)

INNER JOIN returns all rows from the left table; LEFT JOIN returns only unmatched rows from the right table.

d)

INNER JOIN returns all rows from both tables; LEFT JOIN returns only matching rows.

3.

What is a subquery and when would you use one?

a)

A subquery is a nested query used to retrieve data based on another query's results.

b)

A subquery is a type of database index.

c)

A subquery is a method for data encryption.

d)

A subquery is used to create new tables.

4.

How can you optimize a query using indexing?

a)

Use a single index for all columns to reduce complexity.

b)

Create indexes on frequently queried columns to improve query performance.

c)

Create indexes on rarely queried columns to save space.

d)

Avoid using indexes as they slow down all queries.

5.

What are the types of indexes available in SQL?

a)

Tree, Hashmap, Bitmap, Text

b)

B-tree, Hash, Bitmap, XML, Spatial

c)

B-tree, Hash, Bitmap, Full-text, Graph

d)

B-tree, Hash, Bitmap, Full-text, Spatial

6.

How does indexing affect the performance of data retrieval?

a)

Indexing has no impact on query performance.

b)

Indexing slows down data retrieval by increasing search time.

c)

Indexing significantly enhances data retrieval speed by reducing search time and improving query performance.

d)

Indexing complicates data retrieval processes.

7.

What is the purpose of the Data Manipulation Language (DML)?

a)

To define the structure of a database.

b)

To create new database tables.

c)

The purpose of DML is to manipulate data in a database.

d)

To manage user permissions in a database.

8.

List the main DML commands in SQL.

a)

SHOW, DESCRIBE, EXPLAIN, RENAME

b)

FETCH, JOIN, MERGE, INDEX

c)

INSERT, UPDATE, DELETE, SELECT

d)

CREATE, ALTER, DROP, TRUNCATE

9.

How do you insert data into a table using SQL?

a)

INSERT INTO table_name (column1, column2) VALUES (value1, value2);

b)

SELECT * FROM table_name;

c)

DELETE FROM table_name WHERE condition;

d)

UPDATE table_name SET column1 = value1;

10.

What is the syntax for updating records in a SQL table?

a)

SELECT * FROM table_name WHERE condition;

b)

INSERT INTO table_name VALUES (value1, value2);

c)

UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;

d)

DELETE FROM table_name WHERE condition;

11.

Explain the use of the DELETE statement in SQL.

a)

The DELETE statement is used to create a new table in SQL.

b)

The DELETE statement is used to add new rows to a table in SQL.

c)

The DELETE statement is used to update existing rows in a table in SQL.

d)

The DELETE statement is used to remove rows from a table in SQL.

12.

What are aggregate functions in SQL?

a)

Aggregate functions in SQL return multiple values from a set of data.

b)

Aggregate functions in SQL are only applicable to string values.

c)

Aggregate functions in SQL are functions that perform calculations on a set of values and return a single value.

d)

Aggregate functions in SQL are used to modify data types.

13.

Give examples of commonly used aggregate functions.

a)

ADD, SUBTRACT, DIVIDE

b)

TOTAL, MEAN, RANGE

c)

FIRST, LAST, AVERAGE

d)

SUM, AVG, COUNT, MAX, MIN

14.

How do you use the GROUP BY clause with aggregate functions?

a)

Use GROUP BY without any aggregate functions.

b)

You can only use GROUP BY with numeric data types.

c)

Use SELECT with aggregate functions and GROUP BY to group results.

d)

GROUP BY is only for sorting data.

15.

What is a stored procedure in SQL?

a)

A stored procedure is a precompiled collection of SQL statements that can be executed as a single unit.

b)

A stored procedure is a temporary table used for data storage.

c)

A stored procedure is a command to create a new database.

d)

A stored procedure is a type of database index.

16.

How do you create a stored procedure in SQL?

a)

CREATE TABLE table_name (columns);

b)

ALTER PROCEDURE procedure_name (parameters);

c)

CREATE FUNCTION function_name (parameters) BEGIN SQL_statements; END;

d)

CREATE PROCEDURE procedure_name (parameters) BEGIN SQL_statements; END;

17.

What are the advantages of using stored procedures?

a)

Increased complexity in code management

b)

Slower execution times

c)

Reduced data security risks

d)

Advantages of using stored procedures include improved performance, enhanced security, easier maintenance, and data integrity enforcement.

18.

How can you pass parameters to a stored procedure?

a)

You can only pass parameters as global variables.

b)

You can pass parameters by defining them in the procedure and providing values during the call.

c)

Stored procedures do not accept any parameters.

d)

Parameters can only be passed as JSON objects.

19.

What is the difference between a function and a stored procedure?

a)

A stored procedure returns a value; a function performs actions without returning a value.

b)

A function is always faster than a stored procedure in execution.

c)

A function can only be used in SQL queries; a stored procedure cannot.

d)

A function returns a value; a stored procedure performs actions without returning a value.

20.

How do you handle errors in stored procedures?

a)

Use TRY...CATCH blocks for error handling.

b)

Use a global error handler instead of TRY...CATCH.

c)

Log errors to a file without handling them.

d)

Ignore errors and continue execution.

21.

A primary key can be NULL in the table? TRUE or FALSE

a)

TRUE

b)

FALSE

22.

7. _________ helps to set a limit value placed for a field.

a)

DEFAULT Constraint

b)

Primary Key Constraint

c)

Check Constraint

d)

TABLE CONSTRAINT

23.

6. ___________ which helps to uniquely identify a record.

a)

Primary key Constraint

b)

Unique Constraint

c)

Default constraint

d)

Check constraint

24.

5. ___________ constraint ensures that no two rows have the same value in the specified columns.

a)

Primary Key

b)

Unique

c)

Default

d)

Check

25.

Which option is not the command of DML ?

a)

insert

b)

update

c)

alter

d)

delete

26.

A _____ is a place where we can used to store huge amounts of structured data from different databases in a one place.

a)

database

b)

data lake

c)

cloud

d)

data warehouse

27.

Is images and videos being the example of the Structured data?

a)

Yes

b)

No

28.

Less than or equal to?

a)

>=

b)

=>

c)

=<

d)

<=

29.

An SQL command used to add record in a table.

a)

Insert

b)

Create

c)

Update

d)

Add

30.
Which of the following is NOT a type of SQL constraint?
a)
Primary Key
b)
Foreign Key
c)
Alternate Key
d)
Unique
e)
NOT NULL
31.

Which is not the sub language of SQL?

a)

DDL

b)

DML

c)

DCL

d)

PCL

32.

Which would show all fields from the Pupils table?

a)

SELECT * FROM Pupils

b)

SELECT Name, Form FROM Pupils

c)

SELECT * FROM *

d)

SELECT * FROM Forms

33.

With SQL, how do you select all the records from a table named "Persons" where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?

a)

SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

b)

SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName<'Pettersen'

c)

SELECT LastName>'Hansen' AND LastName<'Pettersen' FROM Persons

34.

With SQL, how do you select all the records from a table named "Persons" where the "FirstName" is "Peter" and the "LastName" is "Jackson"?

a)

SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

b)

SELECT * FROM Persons WHERE FirstName<>'Peter' AND LastName<>'Jackson'

c)

SELECT FirstName='Peter', LastName='Jackson' FROM Persons

35.

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='a'

b)

SELECT * FROM Persons WHERE FirstName LIKE 'a%'

c)

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

d)

SELECT * FROM Persons WHERE FirstName LIKE '%a'

36.

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

a)

SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'

b)

SELECT [all] FROM Persons WHERE FirstName='Peter'

c)

SELECT * FROM Persons WHERE FirstName='Peter'

d)

SELECT * FROM Persons WHERE FirstName<>'Peter'

37.

With SQL, how do you select all the columns from a table named "Persons"?

a)

SELECT [all] FROM Persons

b)

SELECT Persons

c)

SELECT * FROM Persons

d)

SELECT *.Persons

38.

To remove duplicate rows from the results of an SQL SELECT statement, the ________ qualifier specified must be included

a)

ONLY

b)

UNIQUE

c)

DISTINCT

d)

SINGLE

39.

The command to eliminate a table from a database is:

a)

REMOVE TABLE CUSTOMER;

b)

DROP TABLE CUSTOMER;

c)

DELETE TABLE CUSTOMER;

d)

UPDATE TABLE CUSTOMER;

40.

The command to remove rows from a table ‘CUSTOMER’ is:

a)

REMOVE FROM CUSTOMER …

b)

DROP FROM CUSTOMER …

c)

DELETE FROM CUSTOMER WHERE …

d)

UPDATE FROM CUSTOMER …