The culmination of the great God--sixth chapter of business, attempt and index

Source: Internet
Author: User

What is a transaction:

A transaction is a mechanism, a sequence of operations, that contains a set of database operations commands and submits or revokes an operation request to the system as a whole. A transaction is an indivisible whole, multiple executions in a transaction, die. Either the execution succeeds or both fail

Four features of a transaction:

Atomicity: A transaction is a complete operation, and the elements of a transaction are non-divided

Consistency: When the transaction is complete, the data must be in a consistent state. In other words, the data stored in the database is in a consistent state before the transaction begins.

Isolation: All concurrent transactions that modify data are isolated from each other, indicating that the transaction must be independent and that it should not rely on or affect other transactions in any way.

Persistence: The persistence of a transaction means that the result of the transaction is permanent regardless of whether the system has failed

How to perform a transaction:

1. Syntax for executing a transaction:

(1) Start transaction: BEGIN TRANSACTION display marks the starting point of a transaction

(2) Commit TRANSACTION COMMIT TRANSACTION a transaction successfully ended

(3) rollback (undo) Transaction: ROLLBACK TRANSACTION clears all data update operations from the start of the transaction to the statement, rolls back the data state to the beginning of the transaction, and frees the resource of the transaction control

2. Classification of transactions:

Show transactions:

Hermit Affairs:

Autocommit transaction: The default mode for SQL Server, which treats each individual T~sql statement as a transaction, and automatically commits if executed successfully, and automatically rolls back if an error occurs

3. Transaction Application Example

The following principles are adhered to when writing a transaction:

Transaction as brief as possible

Minimizing the amount of data accessed in a transaction

Querying data is to try not to use transactions

Try not to wait for user input during the transaction process

What is an index:

An index is an internal method of SQL Server orchestration data, which is a direct channel for retrieving data in a table

Index classification:

1. Unique index: Unique index does not allow two rows to have the same index value

2. Primary KEY index: Primary key index is a special type of unique index

3. Clustered index: The physical order of the table is the same as the logical order of the key value

4. Nonclustered index: The location where records can be found from the index when querying data

5. Composite index: Multiple columns can be co-indexed

6. Full-Text indexing: A special type of marker-based functional index

The culmination of the great God--sixth chapter of business, attempt and index

Related Article

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.