Databricks Data Engineer Associate Question 320
Single answerYou are working on a Databricks Lakehouse project and need to add a comment to an existing Delta table to describe its purpose. Which of the following commands would correctly add a comment to the table?
- A
ALTER TABLE sales_data SET COMMENT 'This table contains monthly sales data.'
- B
COMMENT ON TABLE sales_data IS 'This table contains monthly sales data.'
- C
ALTER TABLE sales_data ADD COMMENT 'This table contains monthly sales data.'
- D
UPDATE TABLE sales_data COMMENT 'This table contains monthly sales data.'
Show answer and explanation
Correct answer: A
Explanation
In Databricks, to add a comment to an existing table, the correct syntax is to use the ALTER TABLE command followed by SET COMMENT. The other options are either unsupported in Databricks or contain invalid syntax.
- A. Correct.
This is the correct syntax in Databricks to add a comment to an existing table using the ALTER TABLE command.
- B. Incorrect.
This syntax is incorrect because the COMMENT ON TABLE statement is not supported in Databricks.
- C. Incorrect.
This syntax is invalid as the ADD COMMENT clause is not a valid SQL construct in Databricks.
- D. Incorrect.
This syntax is incorrect because the UPDATE TABLE statement does not support adding comments.