Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the SQL statement to start a transaction.
SQL
BEGIN [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using COMMIT or ROLLBACK to start a transaction.
Omitting the TRANSACTION keyword.
✗ Incorrect
The BEGIN TRANSACTION statement starts a new transaction in SQL.
2fill in blank
mediumComplete the SQL statement to save changes permanently.
SQL
[1] TRANSACTION; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using BEGIN instead of COMMIT to save changes.
Using ROLLBACK which cancels changes.
✗ Incorrect
The COMMIT TRANSACTION statement saves all changes made during the transaction permanently.
3fill in blank
hardFix the error in the SQL statement to undo changes in a transaction.
SQL
ROLLBACK [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ROLLBACK SAVEPOINT instead of ROLLBACK TRANSACTION.
Using COMMIT or BEGIN with ROLLBACK.
✗ Incorrect
The correct syntax to undo changes is ROLLBACK TRANSACTION.
4fill in blank
hardFill both blanks to create a savepoint and rollback to it.
SQL
SAVEPOINT [1]; ROLLBACK TO [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for savepoint and rollback.
Using reserved words as savepoint names.
✗ Incorrect
You create a savepoint named sp1 and rollback to the same savepoint sp1.
5fill in blank
hardFill all three blanks to demonstrate atomicity with a transaction.
SQL
BEGIN [1]; UPDATE accounts SET balance = balance - 100 WHERE id = 1; UPDATE accounts SET balance = balance + 100 WHERE id = 2; [2]; [3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting BEGIN TRANSACTION or COMMIT.
Using SAVEPOINT instead of COMMIT or ROLLBACK here.
✗ Incorrect
This code starts a transaction, updates balances, commits the changes, and includes a rollback option to undo if needed, demonstrating atomicity.