MUHAMMAD AIMAN BIN ZAMRI
19DDT20F2017
DDT-DIPLOMA TEKNOLOGI MAKLUMAT
START TRANSACTION;
COMMIT function is to record all changes in database permanently and automatically end the SQL transaction.
ROLLBACK function is to abort all changes made in database and rolled back it to the previous consistent statement.
Use command END TRANSACTION or COMMIT because it will end the SQL transaction automatically.
EXIT; or QUIT;
START TRANSACTION;
UPDATE Department
SET DepartmentName = ‘JPH’
WHERE DepartmentID = ‘D02’;
COMMIT;
START TRANSACTION;
DELETE FROM DEPARTMENT
WHERE DepartmentName = ‘JTMK’;
ROLLBACK;
This problem can be prevented by using Two Phase Locking(2PL). The lock point is
the moment when transitioning from growing phase to shrinking phase.T6 cannot do
transaction because it doesn’t have access to data that currently being use on T5.T6
can continue the transaction when lock on the T5 release.
The problem that occurred on figure 3 is lost update. This problem occured when
successfully completed update is overridden by other user. For example, the T2 commit
the transaction at t5 but at the same time T1 is write and commit at t6 so the system will
record the update from T1 only.