Oracle Database Quiz Questions

Course Name:Oracle
Chapter Name:Chapter 6 - DML (Data Manipulation Language)
Lesson Content Link:UPSERT
Current Quiz Count:30
Progress
0%
Q1
True / False

The term "UPSERT" in Oracle refers to a combination of INSERT and UPDATE operations.

Q2
True / False

In Oracle, the MERGE statement is used to perform UPSERT operations.

Q3
True / False

The INSERT ... ON DUPLICATE KEY UPDATE syntax is used in Oracle for UPSERT operations.

Q4
True / False

The MERGE statement in Oracle requires a USING clause to specify the source data for the UPSERT operation.

Q5
True / False

In Oracle, the WHEN MATCHED THEN UPDATE clause of the MERGE statement specifies what to do when a match is found.

Q6
True / False

In Oracle, the MERGE statement can only update existing rows but cannot insert new rows.

Q7
True / False

In Oracle, you can use the WHEN NOT MATCHED THEN INSERT clause of the MERGE statement to specify the insertion of new rows.

Q8
True / False

In Oracle, the MERGE statement can be used with complex conditions involving multiple columns.

Q9
True / False

The MERGE statement in Oracle can be optimized using indexes on the target table.

Q10
True / False

The Oracle Certified Professional (OCP) exam includes knowledge on using the MERGE statement for UPSERT operations and optimizing its performance.

Q11
Single Choice

What is the primary use of the MERGE statement in Oracle?

Q12
Single Choice

In Oracle, what keyword is used to specify the action for matching rows in a MERGE statement?

Q13
Single Choice

Which of the following is required in an Oracle MERGE statement?

Q14
Single Choice

Consider the following Oracle MERGE statement:What will happen if there is no matching row in target_table for an id present in source_table?

SQL Code
MERGE INTO target_table t
USING source_table s
ON (t.id = s.id)
WHEN MATCHED THEN
 UPDATE SET t.value = s.value
WHEN NOT MATCHED THEN
 INSERT (id, value) VALUES (s.id, s.value);
Q15
Single Choice

What is the purpose of the ON clause in an Oracle MERGE statement?

Q16
Single Choice

Consider the following Oracle MERGE statement:If updates contains duplicate employee_id values, what will Oracle do?

SQL Code
MERGE INTO employees e
USING updates u
ON (e.employee_id = u.employee_id)
WHEN MATCHED THEN
 UPDATE SET e.salary = u.salary
WHEN NOT MATCHED THEN
 INSERT (employee_id, salary) VALUES (u.employee_id, u.salary);
Q17
Single Choice

What will be the result of the following Oracle MERGE statement if a NULL value is encountered in the source_table?

SQL Code
MERGE INTO target_table t
USING source_table s
ON (t.id = s.id)
WHEN MATCHED THEN
 UPDATE SET t.value = s.value
WHEN NOT MATCHED THEN
 INSERT (id, value) VALUES (s.id, s.value);
Q18
Single Choice

Consider the following MERGE statement:What does the WHERE clause do in this Oracle MERGE statement?

SQL Code
MERGE INTO orders o
USING order_updates u
ON (o.order_id = u.order_id)
WHEN MATCHED THEN
 UPDATE SET o.status = u.status
WHEN NOT MATCHED THEN
 INSERT (order_id, status) VALUES (u.order_id, u.status)
 WHERE u.status IS NOT NULL;
Q19
Single Choice

In Oracle, what will happen if the USING clause in a MERGE statement returns no rows?

Q20
Single Choice

Consider the following MERGE statement used in an Oracle certification exam:Which of the following actions will be performed if pu.new_stock is negative?

SQL Code
MERGE INTO product_inventory pi
USING product_updates pu
ON (pi.product_id = pu.product_id)
WHEN MATCHED THEN
 UPDATE SET pi.stock = pi.stock + pu.new_stock
WHEN NOT MATCHED THEN
 INSERT (product_id, stock) VALUES (pu.product_id, pu.new_stock);
Q21
Multiple Choice

Identify the SQL scripts that correctly perform a basic UPSERT operation using the MERGE statement in Oracle.

SQL Code
You need to insert a new record into the 'employees' table if it does not exist, or update the existing record if it does. Implement this using the MERGE statement.

Which of the following SQL scripts correctly implement this scenario?
Q22
Multiple Choice

Select the SQL scripts that correctly handle an UPSERT operation with multiple conditions in Oracle.

SQL Code
You need to perform an UPSERT operation on the 'orders' table, where you update the order details if the order_id and customer_id match, or insert a new record if not. Implement this using the MERGE statement.

Which of the following SQL scripts correctly implement this scenario?
Q23
Multiple Choice

Determine the SQL scripts that correctly perform an UPSERT operation with calculated fields in Oracle.

SQL Code
You need to perform an UPSERT operation on the 'inventory' table, where you update the stock quantity by adding the incoming stock if the item already exists, or insert a new record with the incoming stock as the initial quantity. Implement this using the MERGE statement.

Which of the following SQL scripts correctly implement this scenario?
Q24
Multiple Choice

Identify the SQL scripts that correctly handle an UPSERT operation with NULL checks in Oracle.

SQL Code
You need to perform an UPSERT operation on the 'products' table, where you update the product price if the product_id exists, or insert a new record if not, ensuring that NULL values in the source are not overwritten. Implement this using the MERGE statement.

Which of the following SQL scripts correctly implement this scenario?
Q25
Multiple Choice

Select the SQL scripts that correctly perform an UPSERT operation with a sequence in Oracle.

SQL Code
You need to perform an UPSERT operation on the 'transactions' table, where a new transaction record is inserted if it does not exist, and a sequence-generated ID is assigned. If the transaction exists, the transaction date is updated. Implement this using the MERGE statement.

Which of the following SQL scripts correctly implement this scenario?
Q26
Multiple Choice

Identify the SQL scripts that correctly handle an UPSERT operation with error handling in Oracle.

SQL Code
You need to perform an UPSERT operation on the 'customers' table, where a new customer is inserted if they do not exist, or their information is updated if they do, while handling any potential errors. Implement this using the MERGE statement with error handling.

Which of the following SQL scripts correctly implement this scenario?
Q27
Multiple Choice

Select the SQL scripts that correctly perform an UPSERT operation with conditional logic in Oracle.

SQL Code
You need to perform an UPSERT operation on the 'employees' table, where the 'salary' is updated if the employee exists and their current salary is below a threshold, or a new record is inserted otherwise. Implement this using the MERGE statement with conditional logic.

Which of the following SQL scripts correctly implement this scenario?
Q28
Multiple Choice

Determine the SQL scripts that correctly handle an UPSERT operation with data transformations in Oracle.

SQL Code
You need to perform an UPSERT operation on the 'sales' table, where the 'total_amount' is updated or inserted after applying a discount if the sale exists, or a new record with the discounted amount is inserted if not. Implement this using the MERGE statement with data transformations.

Which of the following SQL scripts correctly implement this scenario?
Q29
Multiple Choice

Identify the SQL scripts that correctly perform an UPSERT operation with date-based conditions in Oracle.

SQL Code
You need to perform an UPSERT operation on the 'subscriptions' table, where the subscription is updated if the end_date is in the future, or a new record is inserted if not. Implement this using the MERGE statement with date-based conditions.

Which of the following SQL scripts correctly implement this scenario?
Q30
Multiple Choice

Select the SQL scripts that correctly perform an UPSERT operation with a WHERE clause in Oracle.

SQL Code
You need to perform an UPSERT operation on the 'users' table, where a new record is inserted if it does not exist, or the user's status is updated to 'Active' only if the current status is 'Inactive'. Implement this using the MERGE statement with a WHERE clause.

Which of the following SQL scripts correctly implement this scenario?