
Answer-first summary for fast verification
Answer: Use the `ALTER TABLE SET TBLPROPERTIES` command to set the `comment` property of the table to the desired comment. This method directly modifies the table properties, ensuring the comment is stored with the table metadata and is easily accessible., Use the `COMMENT ON TABLE` command to specify the comment for the table, providing a brief description of its purpose or content. This is the standard SQL approach and is supported in Databricks for Delta tables, making it familiar to most SQL users.
Option A is the best choice because it directly modifies the table properties to include the comment, ensuring the comment is stored as part of the table's metadata. This method is cost-effective, complies with data governance policies by maintaining metadata within the table, and is scalable as it does not require additional resources. The comment is also easily viewable by other team members through standard metadata inspection commands. While Option B is also correct and follows standard SQL practices, Option A is more aligned with the specific requirements of being cost-effective, compliant, and scalable.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
In a scenario where you are working with Delta Lake tables in Databricks and need to add metadata to a table to provide additional information about its purpose or content, consider the following requirements: the solution must be cost-effective, comply with data governance policies, and easily scalable. Additionally, the method should allow for the comment to be easily viewed by other team members. Given these constraints, which of the following methods is the BEST to add a table comment, and why? Choose one option.
A
Use the ALTER TABLE SET TBLPROPERTIES command to set the comment property of the table to the desired comment. This method directly modifies the table properties, ensuring the comment is stored with the table metadata and is easily accessible.
B
Use the COMMENT ON TABLE command to specify the comment for the table, providing a brief description of its purpose or content. This is the standard SQL approach and is supported in Databricks for Delta tables, making it familiar to most SQL users.
C
Use the DESCRIBE TABLE command with the INCLUDE PROPERTIES option to view the current table properties, including any existing comments. This method is useful for viewing comments but does not allow for adding or modifying them.
D
Use the SHOW TABLES command with the LIKE or REGEXP option to filter the list of tables and identify the table you want to add a comment to. This method helps in locating the table but does not support adding comments.