Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Q3-CPO PT

Total questions: 48

Worksheet time: 25mins

Name
Class
Date
1.

Which SQL keyword is used to filter the records?

a)

SORT BY

b)

WHERE

c)

ORDER BY

d)

GROUP BY

2.

What is the SQL keyword used to sort the results in ascending or descending order?

a)

SORT

b)

ORDER

c)

ORDER BY

d)

GROUP BY

3.

Which SQL keyword is used to return records where column values fall within a specified range?

a)

WHERE

b)

BETWEEN

c)

LIKE

d)

IN

4.

What is the default sorting order of the "ORDER BY" clause in SQL?

a)

Descending

b)

Ascending

c)

Random

d)

Random

5.

In SQL, how do you select only distinct (different) values from a column?

a)

SELECT DIFFERENT column_name FROM table_name;

b)

SELECT DISTINCT column_name FROM table_name;

c)

SELECT UNIQUE column_name FROM table_name;

d)

SELECT column_name FROM table_name DISTINCT;

6.

Which SQL operator is used to filter the records to include only those where the column value matches one of several specified values?

a)

BETWEEN

b)

LIKE

c)

IN

d)

OR

7.

What SQL keyword is used to sort multiple columns?

a)

SORT BY

b)

ORDER BY

c)

GROUP BY

d)

ARRANGE BY

8.

Display the output based on the scripts provided: SELECT * FROM Employees WHERE Salary > 90000;

a)

Display all columns from the Employees table where the Salary is greater than 90000.

b)

Display only the Salary column from the Employees table where the Salary is greater than 90000.

c)

Display all columns from the Employees table where the Salary is exactly 90000.

d)

Display an error message because the WHERE clause syntax is incorrect.

9.

Display the output based on the scripts provided: SELECT Name, Position FROM Employees WHERE Position = 'HR' OR Position = 'Sales';

a)

Display all columns from the Employees table where the Position is either 'HR' or 'Sales'.

b)

Display only the Name and Position columns from the Employees table where the Position is either 'HR' or 'Sales'.

c)

Display an error message because the OR operator cannot be used in the WHERE clause.

d)

Display all columns from the Employees table where the Position is 'HR' and 'Sales'.

10.

Display the output based on the scripts provided: SELECT * FROM Employees ORDER BY Salary DESC;

a)

Display all columns from the Employees table in ascending order of Salary.

b)

Display all columns from the Employees table in descending order of Salary.

c)

Display an error message because the ORDER BY clause cannot be used with SELECT *.

d)

Display all columns from the Employees table where the Salary is greater than or equal to 0.

11.

Display the output based on the scripts provided: SELECT * FROM Employees WHERE Salary BETWEEN 50000 AND 80000 ORDER BY Salary ASC;

a)

Display all columns from the Employees table where the Salary is between 50000 and 80000 in ascending order of Salary.

b)

Display all columns from the Employees table where the Salary is between 50000 and 80000 in descending order of Salary.

c)

Display an error message because the ORDER BY clause cannot be used with the BETWEEN operator.

d)

Display all columns from the Employees table where the Salary is greater than or equal to 50000 and less than or equal to 80000 in ascending order of Salary.

12.

Review the script. Determine whether or not it is erroneous or not. The goal of the script is to display all rows with Name having ‘Doe” in it: SELECT * FROM Employees WHERE Name = ‘Doe’;

a)

The script is correct and will display all rows where the Name column exactly matches 'Doe'.

b)

The script is incorrect because it uses the wrong comparison operator for text matching.

c)

The script is incorrect because it should use the LIKE operator for partial text matching.

d)

The script is incorrect because it should use the CONTAINS operator for text matching.

13.

Which SQL function is used to convert a value from one data type to another?

a)

CONVERT

b)

CAST

c)

TRANSFORM

d)

CHANGE

14.

What is the function used in SQL to convert a string to a number?

a)

TO_NUMBER

b)

CAST

c)

CONVERT

d)

TO_STRING

15.

Which SQL function is used to return the current date and time?

a)

NOW()

b)

DATE()

c)

CURRENT_TIME()

d)

GETDATE()

16.

In SQL, which function is used to return a value if a condition is TRUE, and another value if it is FALSE?

a)

IF

b)

CASE

c)

IIF

d)

SWITCH

17.

Display the output based on the scripts provided: SELECT OrderID, Product, Quantity, COALESCE(CAST(Price AS VARCHAR), 'Not Available') AS Price FROM Orders;

a)

Display OrderID, Product, Quantity, and Price columns from the Orders table, converting Price to VARCHAR and displaying 'Not Available' if Price is NULL.

b)

Display OrderID, Product, Quantity, and Price columns from the Orders table, converting Price to VARCHAR and displaying 'Available' if Price is NULL.

c)

Display OrderID, Product, Quantity, and Price columns from the Orders table, converting Price to VARCHAR and displaying NULL if Price is NULL.

d)

Display OrderID, Product, Quantity, and Price columns from the Orders table, converting Price to VARCHAR and displaying 0 if Price is NULL.

18.

Review the script. Determine whether or not it is erroneous or not. The goal of the script is to display all rows with Name having ‘Doe” in it: SELECT * FROM Employees WHERE Name = ‘Doe’;

a)

The script is correct and will display all rows where the Name column exactly matches 'Doe'.

b)

The script is incorrect because it uses the wrong comparison operator for text matching.

c)

The script is incorrect because it should use the LIKE operator for partial text matching.

d)

The script is incorrect because it should use the CONTAINS operator for text matching.

19.

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

a)

CREATE TABLE

b)

ADD TABLE

c)

NEW TABLE

d)

INSERT TABLE

20.

What is the SQL command to delete a table?

a)

REMOVE TABLE

b)

DELETE TABLE

c)

DROP TABLE

d)

ERASE TABLE

21.

Which SQL command is used to add a new column to an existing table?

a)

ADD COLUMN

b)

INSERT COLUMN

c)

ALTER TABLE

d)

UPDATE TABLE

22.

Which SQL statement is used to rename a column in a table?

a)

RENAME COLUMN

b)

ALTER COLUMN

c)

CHANGE COLUMN

d)

MODIFY COLUMN

23.

In SQL, which command is used to delete only the data inside a table, not the table itself?

a)

DELETE

b)

DROP

c)

TRUNCATE

d)

REMOVE

24.

What SQL command is used to modify the data type of a column in a table?

a)

ALTER TABLE

b)

CHANGE COLUMN

c)

MODIFY COLUMN

d)

UPDATE COLUMN

25.

How do you specify a primary key while creating a table in SQL?

a)

PRIMARY KEY

b)

KEY PRIMARY

c)

MAIN KEY

d)

UNIQUE KEY

26.

Explain what will happen when the script below is ran:

CREATE TABLE products (

id INT PRIMARY KEY,

name VARCHAR(50),

price DECIMAL(10, 2)

);

a)

It will create a table named "products" with three columns: "id" of type INT as the primary key, "name" of type VARCHAR with a maximum length of 50 characters, and "price" of type DECIMAL with precision 10 and scale 2.

b)

It will create a table named "products" with two columns: "name" of type VARCHAR with a maximum length of 50 characters, and "price" of type DECIMAL with precision 10 and scale 2, but it will not create the "id" column because it is missing the data type for the "id" column.

c)

It will generate a syntax error because the data type for the "id" column is not specified.

d)

It will create a table named "products" with two columns: "id" of type INT as the primary key, and "price" of type DECIMAL with precision 10 and scale 2, but it will not create the "name" column because it is missing from the script.

27.

Explain what will happen when this script is ran: ALTER TABLE users ADD COLUMN role VARCHAR(20) DEFAULT 'user';

a)

It will create a new table called "users" with a column named "role" of type VARCHAR with a default value of 'user'.

b)

It will modify the existing "users" table by adding a new column named "role" of type VARCHAR with a default value of 'user'.

c)

It will delete the "users" table and create a new table with a column named "role" of type VARCHAR and a default value of 'user'.

d)

It will rename the "users" table to "role" and set its column type to VARCHAR with a default value of 'user'.

28.

Explain what will happen when this script is ran: DROP TABLE IF EXISTS products;  

a)

It will create a new table named "products" if it doesn't already exist in the database.

b)

It will drop the table "products" if it exists in the database, without checking for any dependencies.

c)

It will display an error message because the syntax is incorrect.

d)

It will alter the table "products" by adding a new column named "IF EXISTS."

29.

Explain what will happen when this script is ran: CREATE INDEX idx_username ON users (username);

a)

It will create an index named "idx_username" on the "users" table for the column "username."

b)

It will drop the index "idx_username" if it already exists on the "users" table.

c)

It will display an error message because the syntax is incorrect.

d)

It will update the "users" table by adding a new column named "idx_username."

30.

Review the script. Determine whether or not it is erroneous or not. The goal of the script is to add new a record in the table: INSERT INTO users (id, username, email, password) VALUES (1, 'john_doe', 'john.doe@example.com', 'password123');

a)

The script is erroneous because it attempts to insert a record with an existing ID value (1).

b)

The script is erroneous because it includes the column names in the VALUES clause, which is not allowed in SQL syntax.

c)

The script is correct and will add a new record with the specified values into the "users" table.

d)

The script is erroneous because it contains a password value that is not hashed, which is a security concern.

31.

Which SQL keyword is used to apply a constraint to a table to limit the type of data that can go into a table?

a)

LIMIT

b)

CONSTRAIN

c)

CHECK

d)

RESTRICT

32.

What is a schema in a database?

a)

A collection of database objects, including tables, views, indexes, and synonyms.

b)

A data structure to store data.

c)

A command to manage databases.

d)

A tool to visualize data.

33.

Which SQL statement is used to create a new schema in a database?

a)

CREATE SCHEMA

b)

ADD SCHEMA

c)

NEW SCHEMA

d)

INSERT SCHEMA

34.

Which SQL command is used to delete a schema from a database?

a)

DELETE SCHEMA

b)

DROP SCHEMA

c)

REMOVE SCHEMA

d)

ERASE SCHEMA

35.

What is a view in a database schema?

a)

A virtual table based on the result-set of an SQL statement.

b)

A physical table stored in a database.

c)

A database schema.

d)

A function to view data.

36.

What is an index in a database schema?

a)

A way to find data in a database more quickly.

b)

A method to sort data in a database.

c)

A tool to visualize data.

d)

A command to manage databases.

37.

What is a sequence in a database schema?

a)

A set of numbers or characters in a specific order.

b)

A way to generate unique numbers.

c)

A command to manage databases.

d)

A tool to visualize data.

38.

CREATE TABLE categories (

id INT PRIMARY KEY,

name VARCHAR(50),

description TEXT

);

a)

Create a new table named "categories" with three columns: id, name, and description.

b)

Drop the table "categories" if it already exists in the database.

c)

Insert a new record into the "categories" table.

d)

Update the "categories" table by adding a new column named "id."

39.

Explain what will happen when the script below is ran: ALTER TABLE products ADD COLUMN stock INT DEFAULT 0; 

a)

Create a new table named "products" with four columns: id, name, price, category_id.

b)

Insert three records into the "products" table with specified values.

c)

Add a new column named "stock" to the "products" table with a default value of 0.

d)

Update the "products" table by changing the data type of the "stock" column to INT.

40.

Explain what will happen when the script below is ran: DROP TABLE IF EXISTS categories; 

a)

Create a new table named "categories" if it doesn't already exist.

b)

Drop the table "categories" if it exists in the database.

c)

Display an error message because the syntax is incorrect.

d)

Add a new column named "IF EXISTS" to the "categories" table.

41.

Explain what will happen when the script below is ran: CREATE INDEX idx_name ON products (name);

a)

Create an index named "idx_name" on the "products" table for the column "name."

b)

Drop the index "idx_name" if it already exists on the "products" table.

c)

Display an error message because the syntax is incorrect.

d)

Update the "products" table by adding a new column named "idx_name."

42.

Review the script. Determine whether or not it is erroneous or not. The goal of the script is to add new a record in the table: INSERT INTO products (id, name, price, category_id) VALUES (4, ‘Headphones’, 100.00, 3);

a)

The script is correct and will successfully add a new record to the "products" table.

b)

The script will fail because the ID 4 already exists in the "products" table.

c)

The script will fail because the name "Headphones" already exists in the "products" table.

d)

The script will fail because the category_id 3 does not exist in the "products" table.

43.

What is a Data Dictionary View in a database?

a)

It's a graphical representation of data.

b)

It's a set of read-only tables that provide information about the database.

c)

It's a set of commands to manage databases.

d)

It's a tool to visualize data.

44.

Which of the following is not a type of Data Dictionary View in Oracle Database?

a)

USER views

b)

ALL views

c)

DBA views

d)

SQL views

45.

What information can you find in Data Dictionary Views?

a)

Names of all tables in the database

b)

Names of all users in the database

c)

Information about space usage, integrity constraints, and privileges

d)

All of the above

46.

Which SQL command is used to retrieve information from Data Dictionary Views?

a)

SELECT

b)

SHOW

c)

DISPLAY

d)

VIEW

47.

What is the complete name of our School Principal? 

(a)  

48.

What is our School ID?

(a)