5.38. PostgreSQL TRANSACTION (transaction)

发布时间 : 2025-10-25 12:30:50 UTC      

Page Views: Stats unavailable

TRANSACTION (transaction) is a logical unit in the execution process of database management system, which is composed of a limited sequence of database operations.

Database transactions usually contain a sequence of read / write operations to the database. It includes the following two purposes:

  • It provides a method for the database operation sequence to recover from failure to the normal state, and provides a way for the database to maintain consistency even in the abnormal state.

  • When multiple applications are accessing the database concurrently, you can provide an isolation method between these applications to prevent each other’s operations from interfering with each other.

When a transaction is committed to the database management system (DBMS), DBMS needs to ensure that all operations in the transaction are completed successfully and that the results are permanently saved in the database. If some operations in the transaction are not completed successfully, all operations in the transaction need to be rolled back to the state before the transaction is executed. At the same time, the transaction has no effect on the execution of the database or other transactions, and all transactions seem to be running independently.

5.38.1. Properties of the transaction

Transactions have the following four standard attributes, usually abbreviated to ACID according to their initials:

  • Atomicity: transactions are executed as a whole, and either all or none of the operations on the database are performed.

  • Consistency: transactions should ensure that the state of the database transitions from one consistent state to another. The meaning of consistent state is that the data in the database should meet the integrity constraints.

  • Isolation: when multiple transactions are executed concurrently, the execution of one transaction should not affect the execution of other transactions.

  • Durability: changes made to the database by committed transactions should be permanently saved in the database.

5.38.2. Examples

Someone wants to use electronic money to buy something worth 100 yuan in a store, which includes at least two operations:

  • The person’s account was reduced by 100 yuan.

  • The store account will be increased by 100 yuan.

The database management system that supports transactions is to ensure that the above two operations (the whole “transaction”) can be completed or cancelled together, otherwise 100 yuan will disappear or appear in vain.

5.38.3. Transaction control

Use the following command to control the transaction:

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.