Databricks Data Engineer Associate Question 321
Single answerYou are working on a Databricks Lakehouse project where you need to document the purpose of a table called sales_data. How can you add a comment to the table to describe its purpose?
- A
ALTER TABLE sales_data SET COMMENT 'This table stores sales transactions data.'
- B
COMMENT ON TABLE sales_data IS 'This table stores sales transactions data.'
- C
ADD COMMENT TO TABLE sales_data 'This table stores sales transactions data.'
- D
UPDATE TABLE sales_data COMMENT 'This table stores sales transactions data.'
Show answer and explanation
Correct answer: A
Explanation
In Databricks, the correct way to add a comment to a table is by using the ALTER TABLE ... SET COMMENT statement. The other options either use incorrect syntax or commands that are not applicable in Databricks SQL.
- A. Correct.
This is the correct syntax in Databricks SQL and Delta Lake for adding a comment to a table.
- B. Incorrect.
This syntax is used in some SQL dialects like PostgreSQL but is not valid in Databricks.
- C. Incorrect.
This syntax is invalid as it does not follow the correct command structure for adding a comment to a table in Databricks.
- D. Incorrect.
This syntax is incorrect because the UPDATE command is not used for adding comments to tables in Databricks.