WorksheetsQ3-CPO PT
Total questions: 48
Worksheet time: 25mins
Which SQL keyword is used to filter the records?
SORT BY
WHERE
ORDER BY
GROUP BY
What is the SQL keyword used to sort the results in ascending or descending order?
SORT
ORDER
ORDER BY
GROUP BY
Which SQL keyword is used to return records where column values fall within a specified range?
WHERE
BETWEEN
LIKE
IN
What is the default sorting order of the "ORDER BY" clause in SQL?
Descending
Ascending
Random
Random
In SQL, how do you select only distinct (different) values from a column?
SELECT DIFFERENT column_name FROM table_name;
SELECT DISTINCT column_name FROM table_name;
SELECT UNIQUE column_name FROM table_name;
SELECT column_name FROM table_name DISTINCT;
Which SQL operator is used to filter the records to include only those where the column value matches one of several specified values?
BETWEEN
LIKE
IN
OR
What SQL keyword is used to sort multiple columns?
SORT BY
ORDER BY
GROUP BY
ARRANGE BY
Display the output based on the scripts provided: SELECT * FROM Employees WHERE Salary > 90000;
Display all columns from the Employees table where the Salary is greater than 90000.
Display only the Salary column from the Employees table where the Salary is greater than 90000.
Display all columns from the Employees table where the Salary is exactly 90000.
Display an error message because the WHERE clause syntax is incorrect.
Display the output based on the scripts provided: SELECT Name, Position FROM Employees WHERE Position = 'HR' OR Position = 'Sales';
Display all columns from the Employees table where the Position is either 'HR' or 'Sales'.
Display only the Name and Position columns from the Employees table where the Position is either 'HR' or 'Sales'.
Display an error message because the OR operator cannot be used in the WHERE clause.
Display all columns from the Employees table where the Position is 'HR' and 'Sales'.
Display the output based on the scripts provided: SELECT * FROM Employees ORDER BY Salary DESC;
Display all columns from the Employees table in ascending order of Salary.
Display all columns from the Employees table in descending order of Salary.
Display an error message because the ORDER BY clause cannot be used with SELECT *.
Display all columns from the Employees table where the Salary is greater than or equal to 0.
Display the output based on the scripts provided: SELECT * FROM Employees WHERE Salary BETWEEN 50000 AND 80000 ORDER BY Salary ASC;
Display all columns from the Employees table where the Salary is between 50000 and 80000 in ascending order of Salary.
Display all columns from the Employees table where the Salary is between 50000 and 80000 in descending order of Salary.
Display an error message because the ORDER BY clause cannot be used with the BETWEEN operator.
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.
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’;
The script is correct and will display all rows where the Name column exactly matches 'Doe'.
The script is incorrect because it uses the wrong comparison operator for text matching.
The script is incorrect because it should use the LIKE operator for partial text matching.
The script is incorrect because it should use the CONTAINS operator for text matching.
Which SQL function is used to convert a value from one data type to another?
CONVERT
CAST
TRANSFORM
CHANGE
What is the function used in SQL to convert a string to a number?
TO_NUMBER
CAST
CONVERT
TO_STRING
Which SQL function is used to return the current date and time?
NOW()
DATE()
CURRENT_TIME()
GETDATE()
In SQL, which function is used to return a value if a condition is TRUE, and another value if it is FALSE?
IF
CASE
IIF
SWITCH
Display the output based on the scripts provided: SELECT OrderID, Product, Quantity, COALESCE(CAST(Price AS VARCHAR), 'Not Available') AS Price FROM Orders;
Display OrderID, Product, Quantity, and Price columns from the Orders table, converting Price to VARCHAR and displaying 'Not Available' if Price is NULL.
Display OrderID, Product, Quantity, and Price columns from the Orders table, converting Price to VARCHAR and displaying 'Available' if Price is NULL.
Display OrderID, Product, Quantity, and Price columns from the Orders table, converting Price to VARCHAR and displaying NULL if Price is NULL.
Display OrderID, Product, Quantity, and Price columns from the Orders table, converting Price to VARCHAR and displaying 0 if Price is NULL.
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’;
The script is correct and will display all rows where the Name column exactly matches 'Doe'.
The script is incorrect because it uses the wrong comparison operator for text matching.
The script is incorrect because it should use the LIKE operator for partial text matching.
The script is incorrect because it should use the CONTAINS operator for text matching.
Which SQL statement is used to create a new table in a database?
CREATE TABLE
ADD TABLE
NEW TABLE
INSERT TABLE
What is the SQL command to delete a table?
REMOVE TABLE
DELETE TABLE
DROP TABLE
ERASE TABLE
Which SQL command is used to add a new column to an existing table?
ADD COLUMN
INSERT COLUMN
ALTER TABLE
UPDATE TABLE
Which SQL statement is used to rename a column in a table?
RENAME COLUMN
ALTER COLUMN
CHANGE COLUMN
MODIFY COLUMN
In SQL, which command is used to delete only the data inside a table, not the table itself?
DELETE
DROP
TRUNCATE
REMOVE
What SQL command is used to modify the data type of a column in a table?
ALTER TABLE
CHANGE COLUMN
MODIFY COLUMN
UPDATE COLUMN
How do you specify a primary key while creating a table in SQL?
PRIMARY KEY
KEY PRIMARY
MAIN KEY
UNIQUE KEY
Explain what will happen when the script below is ran:
CREATE TABLE products (
id INT PRIMARY KEY,
name VARCHAR(50),
price DECIMAL(10, 2)
);
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.
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.
It will generate a syntax error because the data type for the "id" column is not specified.
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.
Explain what will happen when this script is ran: ALTER TABLE users ADD COLUMN role VARCHAR(20) DEFAULT 'user';
It will create a new table called "users" with a column named "role" of type VARCHAR with a default value of 'user'.
It will modify the existing "users" table by adding a new column named "role" of type VARCHAR with a default value of 'user'.
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'.
It will rename the "users" table to "role" and set its column type to VARCHAR with a default value of 'user'.
Explain what will happen when this script is ran: DROP TABLE IF EXISTS products;
It will create a new table named "products" if it doesn't already exist in the database.
It will drop the table "products" if it exists in the database, without checking for any dependencies.
It will display an error message because the syntax is incorrect.
It will alter the table "products" by adding a new column named "IF EXISTS."
Explain what will happen when this script is ran: CREATE INDEX idx_username ON users (username);
It will create an index named "idx_username" on the "users" table for the column "username."
It will drop the index "idx_username" if it already exists on the "users" table.
It will display an error message because the syntax is incorrect.
It will update the "users" table by adding a new column named "idx_username."
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');
The script is erroneous because it attempts to insert a record with an existing ID value (1).
The script is erroneous because it includes the column names in the VALUES clause, which is not allowed in SQL syntax.
The script is correct and will add a new record with the specified values into the "users" table.
The script is erroneous because it contains a password value that is not hashed, which is a security concern.
Which SQL keyword is used to apply a constraint to a table to limit the type of data that can go into a table?
LIMIT
CONSTRAIN
CHECK
RESTRICT
What is a schema in a database?
A collection of database objects, including tables, views, indexes, and synonyms.
A data structure to store data.
A command to manage databases.
A tool to visualize data.
Which SQL statement is used to create a new schema in a database?
CREATE SCHEMA
ADD SCHEMA
NEW SCHEMA
INSERT SCHEMA
Which SQL command is used to delete a schema from a database?
DELETE SCHEMA
DROP SCHEMA
REMOVE SCHEMA
ERASE SCHEMA
What is a view in a database schema?
A virtual table based on the result-set of an SQL statement.
A physical table stored in a database.
A database schema.
A function to view data.
What is an index in a database schema?
A way to find data in a database more quickly.
A method to sort data in a database.
A tool to visualize data.
A command to manage databases.
What is a sequence in a database schema?
A set of numbers or characters in a specific order.
A way to generate unique numbers.
A command to manage databases.
A tool to visualize data.
CREATE TABLE categories (
id INT PRIMARY KEY,
name VARCHAR(50),
description TEXT
);
Create a new table named "categories" with three columns: id, name, and description.
Drop the table "categories" if it already exists in the database.
Insert a new record into the "categories" table.
Update the "categories" table by adding a new column named "id."
Explain what will happen when the script below is ran: ALTER TABLE products ADD COLUMN stock INT DEFAULT 0;
Create a new table named "products" with four columns: id, name, price, category_id.
Insert three records into the "products" table with specified values.
Add a new column named "stock" to the "products" table with a default value of 0.
Update the "products" table by changing the data type of the "stock" column to INT.
Explain what will happen when the script below is ran: DROP TABLE IF EXISTS categories;
Create a new table named "categories" if it doesn't already exist.
Drop the table "categories" if it exists in the database.
Display an error message because the syntax is incorrect.
Add a new column named "IF EXISTS" to the "categories" table.
Explain what will happen when the script below is ran: CREATE INDEX idx_name ON products (name);
Create an index named "idx_name" on the "products" table for the column "name."
Drop the index "idx_name" if it already exists on the "products" table.
Display an error message because the syntax is incorrect.
Update the "products" table by adding a new column named "idx_name."
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);
The script is correct and will successfully add a new record to the "products" table.
The script will fail because the ID 4 already exists in the "products" table.
The script will fail because the name "Headphones" already exists in the "products" table.
The script will fail because the category_id 3 does not exist in the "products" table.
What is a Data Dictionary View in a database?
It's a graphical representation of data.
It's a set of read-only tables that provide information about the database.
It's a set of commands to manage databases.
It's a tool to visualize data.
Which of the following is not a type of Data Dictionary View in Oracle Database?
USER views
ALL views
DBA views
SQL views
What information can you find in Data Dictionary Views?
Names of all tables in the database
Names of all users in the database
Information about space usage, integrity constraints, and privileges
All of the above
Which SQL command is used to retrieve information from Data Dictionary Views?
SELECT
SHOW
DISPLAY
VIEW
What is the complete name of our School Principal?
(a)
What is our School ID?
(a)
