Databricks Data Engineer Associate Question 282
Single answerYou are working with a Delta table in Databricks named 'sales_data'. A recent update introduced incorrect data into the table. You decide to roll back the table to a previous valid version. Which command should you use to achieve this?
- A
RESTORE TABLE sales_data TO VERSION AS OF 5
- B
ROLLBACK TABLE sales_data TO VERSION 5
- C
ALTER TABLE sales_data RESET TO VERSION 5
- D
SET TABLE sales_data VERSION 5
Show answer and explanation
Correct answer: A
Explanation
In Databricks, you can use the 'RESTORE TABLE' command to revert a Delta table to a specific version by specifying the version number using 'TO VERSION AS OF'. This is a common operation when you need to undo incorrect changes or recover previous table states.
- A. Correct.
This is the correct syntax for rolling back a Delta table to a previous version. The 'RESTORE TABLE' command allows you to revert the table to a specific version using 'TO VERSION AS OF'.
- B. Incorrect.
This is incorrect because 'ROLLBACK TABLE' is not a valid Databricks SQL or Delta Lake command.
- C. Incorrect.
This is incorrect because 'ALTER TABLE ... RESET TO VERSION' is not a valid command for Delta tables.
- D. Incorrect.
This is incorrect because 'SET TABLE ... VERSION' is not a valid Databricks or Delta Lake command.