SnowPro Advanced: Data Engineer — Question 92

A Data Engineer is debugging a SQL stored procedure that contains a transaction with a rollback using this code:

DROP TABLE A1;
CREATE OR REPLACE TABLE A1(i int);
BEGIN TRANSACTION;
INSERT INTO A1 VALUES (1), (2);
INSERT INTO A1 VALUES (3), (4);
CREATE OR REPLACE TABLE table2 (i VARCHAR);
INSERT INTO A1 VALUES (5), (6);
ROLLBACK;

How many rows will the code write into table A1?

Answer options

Correct answer: D

Explanation

The correct answer is D because the CREATE statement for table2 acts as an implicit commit, finalizing all previous inserts into table A1. Therefore, all six rows (1, 2, 3, 4, 5, and 6) are committed before the ROLLBACK command is executed. Options A, B, and C are incorrect as they misunderstand how implicit commits work in relation to the transaction.