How can you add a clustering key to the existing table MYTABLE in the columns USER and CREATED_AT?

Master the SnowPro Advanced Architect Test with flashcards, multiple-choice questions, and detailed explanations. Prepare thoroughly for your certification!

Multiple Choice

How can you add a clustering key to the existing table MYTABLE in the columns USER and CREATED_AT?

Explanation:
In Snowflake, you add a clustering key to an existing table with a single ALTER TABLE statement that uses CLUSTER BY and lists the columns in parentheses. To create a composite clustering key on USER and CREATED_AT for MYTABLE, you would run: ALTER TABLE MYTABLE CLUSTER BY (USER, CREATED_AT). This attaches both columns as the clustering key in one go. The other options aren’t valid syntax in Snowflake. You can’t issue separate CLUSTER BY clauses for each column, nor use CREATE CLUSTER_KEY or CREATE CLUSTER KEY ON syntax. After applying the clustering key, Snowflake starts background reclustering to optimize data layout for queries involving those columns.

In Snowflake, you add a clustering key to an existing table with a single ALTER TABLE statement that uses CLUSTER BY and lists the columns in parentheses. To create a composite clustering key on USER and CREATED_AT for MYTABLE, you would run: ALTER TABLE MYTABLE CLUSTER BY (USER, CREATED_AT). This attaches both columns as the clustering key in one go.

The other options aren’t valid syntax in Snowflake. You can’t issue separate CLUSTER BY clauses for each column, nor use CREATE CLUSTER_KEY or CREATE CLUSTER KEY ON syntax. After applying the clustering key, Snowflake starts background reclustering to optimize data layout for queries involving those columns.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy