Databricks Data Engineer Associate Question 322
Single answerYou are a data engineer managing a Delta table named sales_data in your Databricks workspace. Your team has requested that you add a description to the table to indicate that it contains monthly sales records. Which SQL command should you use to add a comment to this table?
- A
ALTER TABLE sales_data COMMENT 'Table containing monthly sales records'
- B
COMMENT ON TABLE sales_data IS 'Table containing monthly sales records'
- C
ALTER TABLE sales_data SET COMMENT 'Table containing monthly sales records'
- D
SET COMMENT FOR sales_data AS 'Table containing monthly sales records'
Show answer and explanation
Correct answer: B
Explanation
In Databricks SQL, the proper way to add or update a comment for a table is by using the COMMENT ON TABLE <table_name> IS '<comment>' syntax. This command allows you to clearly specify the table and the associated comment. Other options listed either use invalid syntax or are not supported in Databricks.
- A. Incorrect.
This is not a valid SQL syntax for adding a comment to a table in Databricks.
- B. Correct.
This is the correct syntax in Databricks SQL to add or update a comment on a table.
- C. Incorrect.
This syntax is incorrect because 'SET COMMENT' is not valid SQL syntax in Databricks.
- D. Incorrect.
This syntax is invalid because Databricks does not use 'SET COMMENT FOR' to add a comment to a table.