---
title: "Transactions in database"  
description: "A transaction is a group of events that occur between any of the following events:Connecting to databaseDisconnecting to databaseCommitting changes to"  
author: "Amit Singh"  
published: 2011-05-18  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/175/transactions-in-database  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# Transactions in database

A [transaction](https://www.mindstick.com/blog/125/sql-server-transaction) is a group of events that occur between any of the following events:

· Connecting to database

· Disconnecting to database

· Committing changes to the [database table](https://www.mindstick.com/forum/159366/how-to-test-regular-expressions-in-sql-without-using-database-table)

· Rollback

“A series of one or more SQL statements that are logically related or a series of [operations](https://www.mindstick.com/blog/304985/how-does-devops-bridge-the-gap-between-development-and-operations-teams-like-git) performed on [table data](https://www.mindstick.com/forum/33744/how-to-use-angularjs-table-data-binding-in-asp-dot-net) is [termed as](https://answers.mindstick.com/qa/97007/why-the-standard-of-an-osi-model-is-termed-as-802-xx) a Transaction”.

A transaction begins with the first executable SQL statement after a commit, rollback or [connection](https://www.mindstick.com/articles/13012/what-makes-ethernet-connection-better-than-wifi) made to the database engine. All changes made to a table data via a transaction are made or undone at one instance.

\

##### How to close the transaction

##### \

A transaction can be closed by using either a commit or a rollback statement. By using these statements, table data can be changed or all the changes made to the table data undone.

\

##### COMMIT

A COMMIT ends the current transaction and makes [permanent](https://answers.mindstick.com/qa/50600/what-is-a-permanent-storage-in-pc) any changes made during the transaction. All transactional locks acquired on tables are released.

Syntax

COMMIT

\

##### ROLLBACK

##### \

A ROLLBACK does exactly the opposite of commit. It ends the transaction but undoes any changes made during the transaction. All transactional locks acquired on tables are released.

\

##### Syntax:

ROLLBACK [WORK][TO [SAVEPOINT]<SavepointName>]

Where

WORK Is optional and is provided for ANSI [compatibility](https://yourviews.mindstick.com/story/1513/7-zodiac-signs-astrology-dates-meanings-amp-compatibility)

SAVEPOINT Is optional and is used to rollback a transaction partially (it marks and saves the current point in the [processing](https://www.mindstick.com/blog/254/background-processing-in-android) of a transaction).

SavepontName Is a savepoint created during the current transaction\
\

Rollback must be done with or without the savepoint.

---

Original Source: https://www.mindstick.com/blog/175/transactions-in-database

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
