nerdexam
SnowflakeSnowflake

SOL-C01 · Question #167

SOL-C01 Question #167: Real Exam Question with Answer & Explanation

The correct answer is A: Use a Snowflake Sequence and retrieve its next value in the 'INSERT' statement using `ORDERS. Both options A and C offer efficient and correct ways to implement auto-incrementing ` ORDER_ID' in Snowflake. A utilizes Snowflake Sequences which are designed for generating unique, sequential numbers. C uses the IDENTITY column property, a simpler and more declarative approach

Querying and Performance

Question

You are creating a table 'ORDERS' to store customer orders and need to include an 'ORDER ID' column that automatically increments with each new order. You want to achieve this with minimal manual intervention. What are the two most efficient and correct ways to implement auto- incrementing 'ORDER ID' in Snowflake?

Options

  • AUse a Snowflake Sequence and retrieve its next value in the 'INSERT' statement using `ORDERS
  • BImplement a stored procedure that retrieves the maximum 'ORDER_ID' from the table, increments
  • CDefine as ` IDENTITY column during table creation so the column increments automatically with
  • DCreate a separate table to store the last used 'ORDER ID and update it in a transaction before
  • EInsert a random integer with or functions to create unique ID.

Explanation

Both options A and C offer efficient and correct ways to implement auto-incrementing ` ORDER_ID' in Snowflake. A utilizes Snowflake Sequences which are designed for generating unique, sequential numbers. C uses the IDENTITY column property, a simpler and more declarative approach available in Snowflake. B and D involves writing custom logic that can be prone to errors and is less efficient and less scalable than using built-in features like sequences or identity columns. E does not guarantee the creation of sequential ids.

Topics

#Identity Column#Sequences#Auto-increment#DDL/DML

Community Discussion

No community discussion yet for this question.

Full SOL-C01 PracticeBrowse All SOL-C01 Questions