Q1
True / FalseThe term "UPSERT" in Oracle refers to a combination of INSERT and UPDATE operations.
UPSERT is a database operation that combines INSERT and UPDATE, ensuring that if a row already exists, it is updated, otherwise, a new row is inserted.
Q2
True / FalseIn Oracle, the MERGE statement is used to perform UPSERT operations.
The MERGE statement in Oracle is used to perform UPSERT operations, merging data into a table based on a condition.
Q3
True / FalseThe INSERT ... ON DUPLICATE KEY UPDATE syntax is used in Oracle for UPSERT operations.
This syntax is used in MySQL, not Oracle. Oracle uses the MERGE statement for UPSERT operations.
Q4
True / FalseThe MERGE statement in Oracle requires a USING clause to specify the source data for the UPSERT operation.
The MERGE statement requires a USING clause to specify the source table or subquery that provides the data for the operation.
Q5
True / FalseIn Oracle, the WHEN MATCHED THEN UPDATE clause of the MERGE statement specifies what to do when a match is found.
The WHEN MATCHED THEN UPDATE clause specifies the update operation to perform if a match is found in the target table.
Q6
True / FalseIn Oracle, the MERGE statement can only update existing rows but cannot insert new rows.
The MERGE statement can both update existing rows and insert new rows, depending on whether a match is found.
Q7
True / FalseIn Oracle, you can use the WHEN NOT MATCHED THEN INSERT clause of the MERGE statement to specify the insertion of new rows.
The WHEN NOT MATCHED THEN INSERT clause specifies the insert operation to perform if no match is found in the target table.
Q8
True / FalseIn Oracle, the MERGE statement can be used with complex conditions involving multiple columns.
The MERGE statement can include complex conditions in the ON clause, allowing for detailed matching criteria involving multiple columns.
Q9
True / FalseThe MERGE statement in Oracle can be optimized using indexes on the target table.
Indexes on the target table can help optimize the performance of the MERGE statement by speeding up the matching process.
Q10
True / FalseThe Oracle Certified Professional (OCP) exam includes knowledge on using the MERGE statement for UPSERT operations and optimizing its performance.
The OCP certification covers advanced topics, including how to use the MERGE statement for UPSERT operations and how to optimize its performance, reflecting the candidate's comprehensive knowledge of Oracle database management.
Q21
Multiple ChoiceIdentify 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?
The MERGE statement in Oracle is used to perform an UPSERT operation, where it updates existing records or inserts new ones if they don't exist. The correct scripts will demonstrate the basic usage of MERGE.
Q22
Multiple ChoiceSelect 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?
Handling multiple conditions in an UPSERT operation requires careful use of the ON clause in the MERGE statement. The correct scripts will demonstrate how to handle complex conditions during the UPSERT operation.
Q23
Multiple ChoiceDetermine 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?
When performing an UPSERT with calculated fields, itβs important to correctly calculate the fields during the UPDATE and INSERT operations. The correct scripts will demonstrate how to handle calculations during the UPSERT.
Q24
Multiple ChoiceIdentify 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?
Handling NULL values during an UPSERT requires careful checks to ensure that NULLs in the source data do not overwrite existing non-NULL values in the target. The correct scripts will demonstrate how to implement this.
Q25
Multiple ChoiceSelect 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?
Using a sequence during an UPSERT operation allows for assigning unique IDs to new records. The correct scripts will demonstrate how to use a sequence to populate the ID column in the target table during an UPSERT.
Q26
Multiple ChoiceIdentify 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?
Error handling during an UPSERT operation can be managed using PL/SQL exception handling. The correct scripts will demonstrate how to catch and handle errors during an UPSERT operation.
Q27
Multiple ChoiceSelect 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?
Conditional logic in an UPSERT operation can be implemented using the WHEN MATCHED clause in the MERGE statement. The correct scripts will demonstrate how to apply conditions during the UPSERT operation.
Q28
Multiple ChoiceDetermine 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?
Applying data transformations during an UPSERT operation requires calculating the fields during the UPDATE and INSERT operations. The correct scripts will demonstrate how to handle transformations during the UPSERT.
Q29
Multiple ChoiceIdentify 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?
Date-based conditions during an UPSERT operation can be managed using the WHEN MATCHED clause in the MERGE statement. The correct scripts will demonstrate how to apply date-based conditions during the UPSERT.
Q30
Multiple ChoiceSelect 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?
Using a WHERE clause in the WHEN MATCHED clause of a MERGE statement allows for more precise updates during an UPSERT operation. The correct scripts will demonstrate how to use a WHERE clause to apply conditions during the UPSERT.