Locks in database transactions

Source: Internet
Author: User
I. Transaction criterion (ACID) 1. Atomic execution: either done or not done; 2. Functional Consistency ): DBMS data should be consistent from one State to another; 3. Data Isolation between each other (Isolation): multiple transactions can be executed concurrently, and the same transaction can be isolated from each other: 4. Durab

I. Transaction criterion (ACID) 1. Atomic execution: either done or not done; 2. Functional Consistency ): DBMS data should be consistent from one State to another; 3. Data Isolation between each other (Isolation): multiple transactions can be executed concurrently, and the same transaction can be isolated from each other: 4. Durab

I. Transaction principles (ACID)
1. Atomic execution: either done or not done;
2. Consistency: DBMS data must be consistent from one state to another;
3. Data Isolation between each other (Isolation): multiple transactions can be executed concurrently, and the same transaction can be isolated from each other:
4. Durability: The Impact of transactions on the database is persistent, and the failure should be recoverable.
The actual transaction is a user-defined transaction, which includes a series of operations or statements.
In a multi-server environment, user-defined distributed transactions and Hong Kong servers are used to ensure operation consistency.
Transaction Definition
A transaction refers to the work of a unit, which is either done in full or not done in all. As a logical unit, there must be four

Attributes: automation, consistency, independence, and durability. Automatic means that the transaction must be an automatic unit of work, or execute all

Data modification, or all data modifications are not performed. Consistency means that when the transaction is completed, all data must be consistent.

Status. In relational databases, all rules must be applied to transaction modifications to maintain the integrity of all data. All

Internal data structures, such as links between tree indexes and data, must be confirmed after the transaction ends. Independence refers to parallelism.

The modification of the transaction must be independent from the modification of other parallel transactions. The data seen by one transaction is either modified by another transaction.

The status before the transaction is either the data that has been modified by the second transaction, but this transaction cannot see the data being modified. This

Features are also called seriality. Persistence means that after a transaction is completed, the website space and its impact are permanently generated in the system.

To the database.
The transaction mechanism ensures that the modification of a group of data is either completely executed or not executed. SQL Server uses transactions to ensure data consistency

And ensures recoverability when the system fails. A transaction is the work of a recoverable Unit, composed of one or more-

Grouping SQL statements can affect one or more rows of data in the table. After the transaction is opened, the Hong Kong server is rented until the transaction is submitted after the transaction is successfully completed.

Or until the transaction fails to be fully canceled or rolled back.

Lock is a means to ensure Concurrency Control
Resources that can be locked include rows, pages, clusters, tables, and databases.
The lock types mainly include shared locks and exclusive locks.
Special types of locks include intent locks, modification locks, and mode locks.
The shared lock allows other transactions to continue to use the locked resources.
The exclusive lock allows only one transaction to access data.
The system can handle deadlocks.
You can customize the features of the lock based on the actual situation.
A database is a shared resource used by multiple users. When multiple users access data concurrently, multiple transactions are generated in the database.

When accessing the same data. If you do not control concurrent operations, the system may read and store incorrect data, compromising Database Consistency.

.
Locking is a very important technology for implementing database concurrency control. Before a transaction operates on a data object, it first sends

Request and lock it. After locking, the transaction has certain control over the data object. Before the transaction releases the lock, other transactions do not

This data object can be updated.

Transactions and locks
When a transaction is executed, Oracle will be shackled by the affected table to prevent other users from modifying the table structure. For our users

It is very useful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.