nerdexam
Snowflake

SOL-C01 · Question #303

You are working with a Snowflake Notebook and need to execute a series of SQL statements that include both DDL (Data Definition Language) and DML (Data Manipulation Language) operations. You want to e

The correct answer is E. Create a stored procedure that encapsulates all SQL statements and then call the stored. Rolling back a mixed DDL/DML sequence is fundamentally constrained in Snowflake because DDL statements (CREATE, ALTER, DROP) are auto-committed - they implicitly commit any open transaction and cannot be rolled back. Given this constraint, the most reliable approach is (E) encaps

Querying and Performance

Question

You are working with a Snowflake Notebook and need to execute a series of SQL statements that include both DDL (Data Definition Language) and DML (Data Manipulation Language) operations. You want to ensure that if any statement fails, the entire sequence is rolled back. How can you achieve this within a single Notebook cell?

Options

  • AWrap the SQL statements within a 'BEGIN' and 'END' block within the cell. Snowflake Notebooks
  • BUse the 'snowflake.connector' Python library to explicitly manage transactions using , followed by
  • CPrefix each SQL statement with 'TRY and include a 'CATCH' block at the end to handle any
  • DSnowflake Notebooks do not support transactions within a single cell. Each SQL statement is
  • ECreate a stored procedure that encapsulates all SQL statements and then call the stored

How the community answered

(31 responses)
  • A
    6% (2)
  • B
    6% (2)
  • D
    3% (1)
  • E
    84% (26)

Explanation

Rolling back a mixed DDL/DML sequence is fundamentally constrained in Snowflake because DDL statements (CREATE, ALTER, DROP) are auto-committed - they implicitly commit any open transaction and cannot be rolled back. Given this constraint, the most reliable approach is (E) encapsulating all statements in a stored procedure: Snowflake stored procedures support explicit transaction control (BEGIN/COMMIT/ROLLBACK), and while DDL auto-commit behavior still applies internally, the stored procedure pattern provides the best structure for atomic operation grouping and error handling with ROLLBACK in the exception path. Option A is misleading - BEGIN/END blocks in a notebook cell do not override DDL auto-commit behavior. Option B (snowflake.connector transaction management) could partially work for DML but still cannot roll back DDL. Option C is invalid SQL syntax for Snowflake. Option D is factually incorrect - Snowflake does support transactions, just with the DDL auto-commit caveat.

Topics

#Transactions#Stored Procedures#Snowflake Scripting

Community Discussion

No community discussion yet for this question.

Full SOL-C01 Practice