nerdexam
Snowflake

SOL-C01 · Question #154

You are tasked with creating a table in Snowflake to store customer order data. You need to ensure that the 'order date' column always defaults to the current date if no value is provided during…

The correct answer is A. Option A. Option A is correct because Snowflake uses CURRENT_DATE (no space, as a built-in function) for the default date value and CLUSTER BY (customer_id) - not ORDER BY - to define automatic clustering on a column. Automatic clustering in Snowflake is a micro-partition optimization…

Querying and Performance

Question

You are tasked with creating a table in Snowflake to store customer order data. You need to ensure that the 'order date' column always defaults to the current date if no value is provided during insertion. Additionally, you want to enable automatic clustering on the 'customer id' column to optimize query performance for order retrieval by customer. Which of the following SQL statements correctly date DATE DEFAULT CURRENT DATE) ORDER BY (customer_id); achieves this?

Exhibit

SOL-C01 question #154 exhibit

Options

  • AOption A
  • BOption B
  • COption C
  • DOption D
  • EOption E

How the community answered

(60 responses)
  • A
    85% (51)
  • B
    8% (5)
  • C
    2% (1)
  • D
    2% (1)
  • E
    3% (2)

Explanation

Option A is correct because Snowflake uses CURRENT_DATE (no space, as a built-in function) for the default date value and CLUSTER BY (customer_id) - not ORDER BY - to define automatic clustering on a column. Automatic clustering in Snowflake is a micro-partition optimization feature declared with the CLUSTER BY clause at table creation or via ALTER TABLE, which physically organizes data to improve pruning efficiency for filter-heavy queries on that column. The other options are wrong for one or more of these reasons: using CURRENT DATE (with a space) is invalid Snowflake syntax; using ORDER BY (customer_id) confuses SQL result ordering with Snowflake's clustering concept - ORDER BY has no effect in a CREATE TABLE statement; using DEFAULT NOW() or DEFAULT SYSDATE() may work in other databases but not in Snowflake's preferred syntax; and omitting the CLUSTER BY clause entirely fails the optimization requirement.

Memory tip: Think "CLUSTER, not ORDER" - in Snowflake you cluster your storage, you don't order it. And remember CURRENT_DATE is one word (like a function call), just as CURRENT_TIMESTAMP is - no spaces allowed.

Topics

#Table DDL#Column Defaults#Automatic Clustering#Query Optimization

Community Discussion

No community discussion yet for this question.

Full SOL-C01 Practice