SnowPro Advanced: Architect — Question 110
Instead of updating a particular row, a user forgot to put in the where clause and accidentally updated the entire table, named customer.
The variable error_update_query_id is set to query_id for the mistaken update statement.
How can the current version of the table customer be preserved into the table CUSTOMER_ERROR, and the table CUSTOMER be restored to the version that was in place prior to the update?
Answer options
- A. CREATE TABLE CUSTOMER_ERROR AS CUSTOMER BEFORE(STATEMENT => $error_update_query_id) ALTER TABLE CUSTOMER SWAP WITH CUSTOMER ERROR; __________________________________________________________
- B. CREATE TABLE CUSTOMER_ERROR CLONE CUSTOMER BEFORE(STATEMENT => $error_update_query_id) ALTER TABLE CUSTOMER SWAP WITH CUSTOMER_ERROR; __________________________________________________________
- C. CREATE TABLE CUSTOMER_ERROR LIKE CUSTOMER BEFORE(STATEMENT => $error_update_query_id); ALTER TABLE CUSTOMER SWAP WITH CUSTOMER ERROR; __________________________________________________________
- D. CREATE TABLE CUSTOMER_ERROR AS SELECT * FROM CUSTOMER BEFORE(STATEMENT => $error_update_query_id); __________________________________________________________
Correct answer: D
Explanation
The correct answer, D, effectively creates a new table CUSTOMER_ERROR that captures the state of the CUSTOMER table before the erroneous update using a SELECT statement. Options A, B, and C are incorrect as they either misuse the command structure or do not accurately replicate the desired state of the table prior to the update.