Question:
What does COMMIT do ?
Answer:
COMMIT makes permanent the changes resulting from all SQL statements in the transaction. The changes made by the SQL statements of a transaction become visible to other user sessions transactions that start only after transaction is committed. Source: CoolInterview.com
If you do .... BEGIN insert into tt (1); insert into tt (2); insert into tt (3) END .... COMMIT Now what happens is that all three inserts will either SUCCEED or FAIL. There will never be a case where one insert succeeded and other two failed. It is like ALL or NOTHING. It is asking database to execute ALL of our instructions or NONE. It is like you ask a merchant ... give me 100 bananas at the price of Rs 5 each ...or I dont want to buy anything. If a failure occurs, the database will rollback all transactions that were in the same batch. For ex., you want to transfer Rs 1000 from account A to account B. Now the instructions would be BEGIN (1) Decrement A's account by 1000 (2) Increment B's account by 1000 END; COMMIT If (1) succeeds but (2) fails .... now the database will rollback (1) also. Otherwise you will end up losing money into air. Source: CoolInterview.com
Answered by: rani | Date: 11/20/2008
| Contact rani
COMMIT makes permanent the changes resulting from all SQL statements in the transaction. Source: CoolInterview.com
Answered by: raj | Date: 5/26/2009
| Contact raj
Simply Commit says perminent changes in ur database Source: CoolInterview.com
Answered by: mani | Date: 2/4/2010
| Contact mani
Commit is used to make permanent any changes made to the database during the current transaction which you have made since last commit or rollback. After committing you can't rollback the current transactions. Source: CoolInterview.com
Answered by: Rahul Singhal | Date: 4/24/2016
| Contact Rahul Singhal
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|