Home TechnologyProgrammingSQL & Databases Subscribe to RSS

What Is Commit And Rollback In Sql?

Answer Question

2 Answers - Sort by: Date | Rating

    There are various types of sql queries being used  for different types of database functions. Commit  is used for saving the data that has been changed permanently because whenever you perform any DML (Data Manipulation Language) like UPDATE, INSERT OR DELETE then you are required to write Commit at the end of all or every DML operation in order to save it permanently. If you do not write Commit and you program crashes then your data will be restored into its previous condition. Another key point relating to commit and DML operations is that whenever you perform DML function and then perform some DDL ( data definition language) like creating a  table then the data is auto committed  - no need to write explicit Commit.

    Whereas if you want to restore your data into its previous condition then you can write Rollback at any time after the DML queries has been written but remember once Commit has been written then you cannot rollback the data. Moreover you can only rollback the DML queries that have been written after the last commit statement. The concept of commit and rollback is designed for  data consistency because many uses manipulate data of the same table, using the same database so the user must get updated data.  That is why Commit and Rollback are used.
    1 0

    Toshi76 

    answered 3 years ago

      Commit is to save whatever has been done. It is used to permanently store it in memory.

      Roll-back is to undo something. If we use roll-back, the particular changes made are undone.
      0 0

      Xtatic 

      answered 3 years ago

        More

           
           

          Ask a Question via Twitter

          Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

          Blurtit Store

          Get T-shirts, hoodies, caps and more at the Blurtit store

          Blurtit International