COMMIT & ROLLBACK

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fresher1
    New Member
    • Jan 2008
    • 7

    COMMIT & ROLLBACK

    hi all,

    can anybody tell me the difference between COMMIT and ROLLBACK statements in sql??
    thanks in advance
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    In very basic terms they are both used in conjunction with
    BEGIN TRANS

    after you complete a transacion you are meant to perform a test and if all is ok then you COMMIT the transaction. The transaction is now complete and can't be undone easily.

    If however something went wrong then you ROLLBACK the transaction and everything will be returned to the state it was in before you BEGIN TRANSACTION
    does that make sense?

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Well said Delerna. In addition, ROLLBACK returns to the previous state of the data, NOT the program flow.

      -- CK

      Comment

      • Siva49
        New Member
        • Nov 2011
        • 1

        #4
        Commit : if specifies the commit all the rows updated till that point are permently save in the database, only if the program successfully execute their will be auto commit.

        Rollback : if specifies the rollback, whatever rows updated by the program are reverted or undone. when the program unsuccessfully execute the system will be auto rollback.

        Comment

        Working...