Databricks Data Engineer Associate Question 319
Single answerYou are working with a Delta table named 'sales_data' in your Databricks environment. You want to add a comment to this table for documentation purposes, describing it as 'Contains sales transaction data for the last 5 years'. Which of the following commands will correctly add the comment to the table?
- A
ALTER TABLE sales_data SET COMMENT 'Contains sales transaction data for the last 5 years';
- B
COMMENT ON TABLE sales_data IS 'Contains sales transaction data for the last 5 years';
- C
ALTER TABLE sales_data COMMENT 'Contains sales transaction data for the last 5 years';
- D
ALTER TABLE sales_data ADD COMMENT 'Contains sales transaction data for the last 5 years';
Show answer and explanation
Correct answer: A
Explanation
In Databricks, to add a comment to a table, you use the 'ALTER TABLE ... SET COMMENT' command. The syntax is specific and must match the SQL language supported by Databricks. Other options are incorrect due to unsupported or invalid syntax in Databricks SQL.
- A. Correct.
This is the correct syntax for adding a comment to a table in Databricks using SQL.
- B. Incorrect.
This syntax is incorrect because 'COMMENT ON TABLE' is not supported in Databricks SQL.
- C. Incorrect.
This syntax is invalid as 'ALTER TABLE ... COMMENT' does not exist in Databricks SQL.
- D. Incorrect.
This syntax is invalid as 'ALTER TABLE ... ADD COMMENT' is not a supported command in Databricks SQL.