May 2020
Beginner
564 pages
14h 9m
English
To put a SQL query in a TRANSACTION and COMMIT the transaction, you can use the following sample syntax:
START TRANSACTION;UPDATE tablename SET col1 = 'value1';COMMIT;
To put a SQL query in a TRANSACTION and ROLLBACK the transaction, you can use the following sample syntax:
START TRANSACTION;UPDATE tablename SET col1 = 'value1';ROLLBACK;
To put a SQL query in a TRANSACTION using savepoints to ROLLBACK the transaction, you can use the following sample syntax:
START TRANSACTION;SAVEPOINT firstsavepoint;INSERT INTO tablenameSELECT * FROM anothertablenameWHERE col1 = 'value1';SAVEPOINT secondsavepoint;DELETE FROM tablenameWHERE col1 = 'value2';ROLLBACK TO firstsavepoint;
Read now
Unlock full access