I am trying to simulate a database recovery subsystem using java. However, I have the following questions.
Whenever begin transaction is issued, is it always necessary that there should be an end transaction? (Like the below example)
b1 --- Begin txn 1
r1(X) --- Read item X using txn 1
e1 --- End txn 1
As per the above example, I am not issuing a Commit transaction statement. So, will my transaction succeed or fail? If the above example, is as below,
b1 --- Begin txn 1
r1(X) --- Read item X using txn 1
c1 --- commit txn 1
what is the difference between end and commit?
Please let me know if you need more information.
Either you ROLLBACK a Transaction Or COMMIT a Transaction.I hope you are not confusing it with BEGIN and END block which is not a transaction and nothing to do with Transaction at All.
I believe in most databases .... still it ends with a ROLL BACK or COMMIT.
Hope this helps.
BEGIN/END
delimits a block of code, without controlling a transaction. If not already inside a transaction, each statement will execute in an autonomous transaction. Typically BEGIN/END
is used with branching/looping instructions (IF/WHILE
).
BEGIN TRANSACTION / COMMIT TRANSACTION
denotes the beginning of a transaction: each statement inside this block is executed in the same transaction and cannot be committed or rolled back individually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With