0
0
SQLquery~10 mins

COMMIT and ROLLBACK behavior in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to save changes permanently in the database.

SQL
INSERT INTO employees (name, position) VALUES ('Alice', 'Manager'); [1];
Drag options to blanks, or click blank then click option'
AROLLBACK
BBEGIN
CSAVEPOINT
DCOMMIT
Attempts:
3 left
💡 Hint
Common Mistakes
Using ROLLBACK instead of COMMIT will undo changes.
Forgetting to use COMMIT leaves changes unconfirmed.
2fill in blank
medium

Complete the code to undo changes made in the current transaction.

SQL
UPDATE accounts SET balance = balance - 100 WHERE id = 5; [1];
Drag options to blanks, or click blank then click option'
ACOMMIT
BROLLBACK
CBEGIN TRANSACTION
DSAVEPOINT
Attempts:
3 left
💡 Hint
Common Mistakes
Using COMMIT will save changes instead of undoing them.
Not using ROLLBACK leaves unwanted changes in place.
3fill in blank
hard

Fix the error in the transaction control by choosing the correct command.

SQL
BEGIN TRANSACTION; DELETE FROM orders WHERE order_id = 10; [1];
Drag options to blanks, or click blank then click option'
AROLLBACK
BSTART
CCOMMIT
DSAVEPOINT
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'START' instead of COMMIT causes syntax errors.
Forgetting to commit leaves changes unconfirmed.
4fill in blank
hard

Fill both blanks to create a savepoint and then rollback to it.

SQL
BEGIN TRANSACTION; INSERT INTO products VALUES (101, 'Pen'); [1] save1; UPDATE products SET price = 1.5 WHERE id = 101; [2] save1;
Drag options to blanks, or click blank then click option'
ASAVEPOINT
BCOMMIT
CROLLBACK
DBEGIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using COMMIT instead of ROLLBACK to revert changes.
Not creating a savepoint before rollback.
5fill in blank
hard

Fill all three blanks to start a transaction, create a savepoint, and commit changes.

SQL
[1]; INSERT INTO customers VALUES (201, 'John'); [2] savepoint1; UPDATE customers SET city = 'NY' WHERE id = 201; [3];
Drag options to blanks, or click blank then click option'
ABEGIN TRANSACTION
BSAVEPOINT
CCOMMIT
DROLLBACK
Attempts:
3 left
💡 Hint
Common Mistakes
Using ROLLBACK instead of COMMIT at the end.
Forgetting to begin the transaction.