Databricks Data Engineer Associate Question 318
Single answerYou are working in Databricks and need to add a comment to an existing Delta table named 'sales_data' within the 'analytics' database to clarify its purpose for future users. Which of the following commands will achieve this?
- A
ALTER TABLE analytics.sales_data SET COMMENT 'This table contains monthly sales data.'
- B
COMMENT ON TABLE analytics.sales_data IS 'This table contains monthly sales data.'
- C
ALTER TABLE sales_data ADD COMMENT 'This table contains monthly sales data.'
- D
UPDATE COMMENT ON analytics.sales_data TO 'This table contains monthly sales data.'
Show answer and explanation
Correct answer: A
Explanation
In Databricks, adding or updating a table comment is done using the 'ALTER TABLE ... SET COMMENT' command. This allows users to provide additional metadata to clarify the table's purpose. Other options presented use incorrect or unsupported syntax in Databricks.
- A. Correct.
Correct. The 'ALTER TABLE ... SET COMMENT' command is the correct syntax to add or update a comment on a table in Databricks.
- B. Incorrect.
Incorrect. While this syntax resembles traditional SQL, it is not valid in Databricks for adding comments to tables.
- C. Incorrect.
Incorrect. The 'ADD COMMENT' syntax is not valid in Databricks; the correct syntax is 'SET COMMENT'.
- D. Incorrect.
Incorrect. 'UPDATE COMMENT' is not a valid command in Databricks for modifying table comments.