词条 | Database transaction |
释义 |
A transaction symbolizes a unit of work performed within a database management system (or similar system) against a database, and treated in a coherent and reliable way independent of other transactions. A transaction generally represents any change in a database. Transactions in a database environment have two main purposes:
In a Database Management System, a transaction is a single unit of logic or work, sometimes made up of multiple operations. Any logical calculation done in a consistent mode in a database is known as a transaction. One example is a transfer from one bank account to another: the complete transaction requires subtracting the amount to be transferred from one account and adding that same amount to the other. A database transaction, by definition, must be atomic, consistent, isolated and durable.[1] Database practitioners often refer to these properties of database transactions using the acronym ACID. Transactions provide an "all-or-nothing" proposition, stating that each work-unit performed in a database must either complete in its entirety or have no effect whatsoever. Further, the system must isolate each transaction from other transactions, results must conform to existing constraints in the database, and transactions that complete successfully must get written to durable storage. PurposeDatabases and other data stores which treat the integrity of data as paramount often include the ability to handle transactions to maintain the integrity of data. A single transaction consists of one or more independent units of work, each reading and/or writing information to a database or other data store. When this happens it is often important to ensure that all such processing leaves the database or data store in a consistent state. Examples from double-entry accounting systems often illustrate the concept of transactions. In double-entry accounting every debit requires the recording of an associated credit. If one writes a check for $100 to buy groceries, a transactional double-entry accounting system must record the following two entries to cover the single transaction:
A transactional system would make both entries pass or both entries would fail. By treating the recording of multiple entries as an atomic transactional unit of work the system maintains the integrity of the data recorded. In other words, nobody ends up with a situation in which a debit is recorded but no associated credit is recorded, or vice versa. Transactional databasesA transactional database is a DBMS that provides the ACID properties for a bracketed set of database operations (begin-commit). All the write transactions within a transaction have an all-or-nothing effect, that is, either the transaction succeeds and all updates take effect, or otherwise, the database is brought to a state that does not include any of the updates of the transaction. Transactions also ensure that the effect of concurrent transactions satisfies certain guarantees, known as isolation level. The highest isolation level is serializability, which guarantees that the effect of concurrent transactions is equivalent to their serial (i.e. sequential) execution. Most {{As of|2008|alt=modern}} relational database management systems fall into the category of databases that support transactions. NoSQL data stores prioritize scalability along with supporting transactions in order to guarantee data consistency in the event of concurrent updates and accesses. In a database system, a transaction might consist of one or more data-manipulation statements and queries, each reading and/or writing information in the database. Users of database systems consider consistency and integrity of data as highly important. A simple transaction is usually issued to the database system in a language like SQL wrapped in a transaction, using a pattern similar to the following:
If no errors occurred during the execution of the transaction, then the system commits the transaction. A transaction commit operation applies all data manipulations within the scope of the transaction and persists the results to the database. If an error occurs during the transaction, or if the user specifies a rollback operation, the data manipulations within the transaction are not persisted to the database. In no case can a partial transaction be committed to the database since that would leave the database in an inconsistent state. Internally, multi-user databases store and process transactions, often by using a transaction ID or XID. There are multiple varying ways for transactions to be implemented other than the simple way documented above. Nested transactions, for example, are transactions which contain statements within them that start new transactions (i.e. sub-transactions). Multi-level transactions are a variant of nested transactions where the sub-transactions take place at different levels of a layered system architecture (e.g., with one operation at the database-engine level, one operation at the operating-system level).[2] Another type of transaction is the compensating transaction. In SQLTransactions are available in most SQL database implementations, though with varying levels of robustness. For example, MySQL began supporting transactions from early version 3.23, but the InnoDB storage engine was not default before version 5.5. The earlier available storage engine, MyISAM does not support transactions. A transaction is typically started using the command One can set the isolation level for individual transactional operations as well as globally. At the READ COMMITTED level, the result of any work done after a transaction has commenced, but before it has ended, will remain invisible to other database-users until it has ended. At the lowest level (READ UNCOMMITTED), which may occasionally be used to ensure high concurrency, such changes will be visible. Object databasesRelational databases are traditionally composed of tables with fixed-size fields and records. Object databases comprise variable-sized blobs, possibly serializable or incorporating a mime-type. The fundamental similarities between Relational and Object databases are the start and the commit or rollback. After starting a transaction, database records or objects are locked, either read-only or read-write. Reads and writes can then occur. Once the transaction is fully defined, changes are committed or rolled back atomically, such that at the end of the transaction there is no inconsistency. Distributed transactionsDatabase systems implement distributed transactions[3] as transactions accessing data over multiple nodes. A distributed transaction enforces the ACID properties over multiple nodes, and might include systems such as databases, storage managers, file systems, messaging systems, and other data managers. In a distributed transaction there is typically an entity coordinating all the process to ensure that all parts of the transaction are applied to all relevant systems. Transactional filesystemsThe Namesys Reiser4 filesystem for Linux[4] supports transactions, and as of Microsoft Windows Vista, the Microsoft NTFS filesystem[5] supports distributed transactions across networks. There is occurring research into more data coherent filesystems, such as the Warp Transactional Filesystem (WTF).[6] See also
References1. ^{{cite web|url=http://msdn.microsoft.com/en-us/library/aa366402(VS.85).aspx|title=What is a Transaction? (Windows)|author=|date=|website=msdn.microsoft.com}} 2. ^{{cite journal |last1=Beeri |first1=C. |last2=Bernstein |first2=P. A. |last3=Goodman |first3=N. |title=A model for concurrency in nested transactions systems |journal=Journal of the ACM |volume=36 |issue=1 |pages=230–269 |year=1989 |doi=10.1145/62044.62046}} 3. ^{{Cite book|title=Principles of Distributed Database Systems, Third Edition |publisher=Springer|last=Özsu|first=M. Tamer|last2=Valduriez|first2=Patrick|language=en|doi=10.1007/978-1-4419-8834-8|year = 2011|isbn = 978-1-4419-8833-1}} 4. ^{{cite web|url=https://www.linux.org/|title=Linux.org|author=|date=|website=Linux.org}} 5. ^{{cite web|url=https://msdn.microsoft.com/en-us/library/ff361664(v=vs.110).aspx|title=MSDN Library|publisher=|accessdate=16 October 2014}} 6. ^https://www.usenix.org/system/files/conference/nsdi16/nsdi16-paper-escriva.pdf Further reading
External links
2 : Data management|Transaction processing |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。