SQL Transaction usage and instance rollback, sqltransaction
A transaction executes a series of operations as a unit, either successful or failed, and rolls back to the initial state. In terms of transaction processing, a transaction is either
1 SETAnsi_nulls on2 GO3 SETQuoted_identifier on4 GO5 --Mobile6 --Delete if it exists7 IF(object_id('Trginsert_crm_person_mobile','TR') is not NULL)8 DROP TRIGGERTrginsert_crm_person_mobile9 GOTen --CREATE TRIGGER One CREATE
SQL Server Functions
-- Aggregate functionsUse pubsGoSelect AVG (distinct price) -- calculate the averageFrom titlesWhere type = 'business'
Use pubsGoSelect max (ytd_sales) -- maximum numberFrom titles
Use pubsGoSelect min (ytd_sales) -- Minimum
Why use transactions?When updating multiple tables, an execution fails. Transaction rollback is required to maintain data integrity. Display Set transactions
Begin Try Begin Transaction Insert Into Shiwu (ASD) Values ( ' Aasdasda '
ASP tutorials. NET and SQL processing1: Write directly to SQLWrite SQL statements directly, the SQL statement itself can have transactions, have transactions, in the stored procedure using the BEGIN TRAN,COMMIT Tran rollback TRAN. Advantages:
Delete a message will cascade delete response information, then we need to use the transaction, the following SQL
Copy Code code as follows:
ALTER PROCEDURE [dbo]. [Proc_tb_leaveword_delete]
(
@leavewordID INT,
@record TINYINT OUTPUT
A. Build a library, build a table, and add constraints.
1.1 Building the Library
Copy Code code as follows:
Use master
Go
if exists (SELECT * from sysdatabases where name= ' MyDatabase ')-Determine if there is a database name
1. Four properties of a transactionAtomic Atomicity, consistency consistency, isolation isolation, persistent durability, acid properties.atomicity : A transaction must be a unit of complete work, either fully executed or not executed at
A Program execution unit (unit) that accesses and may update various data items in a database consists of multiple SQL statements that must be executed as a wholeThese SQL statements are submitted to the system as a whole, either executed or not
A transaction executes a sequence of operations as a unit, either succeeds or fails, and rolls back to its original state. In transactional terminology, a transaction is either committed or aborted. To commit a transaction, all participants must
When updating multiple tables, an execution fails. Transaction rollback is required to maintain data integrity.
When updating multiple tables, an execution fails. Transaction rollback is required to maintain data integrity.
Why use
A transaction is the most basic unit of work. Either the entire transaction is completed, or the entire transaction is not operated. this is very important. For example, the SQL statement in the banking system that transfers RMB 10,000 from a
(in the previous article we introduced the " session EJB Series (iii) Sessionbean life cycle ", this is the main introduction of Sessionbean transaction Management)Sessionbean can be functionally divided into two categories:First class: Become EAO:
Java transaction learning notes (9)-in-depth analysis of JTA principles and implementationThrough the study of java transactions in this series, I have a preliminary understanding of the concept of transactions. However, with the rapid development
Why Use Transactions
When more than one table is updated, an execution of the article fails. In order to maintain the integrity of the data, transaction rollback is required.
Show settings transaction
Copy Code code as follows:
Begin
Directory:Interpreting error messagesRAISERRORTHROWInstanceUse @ @ERRORUsing Xact_abortUsing Try/catchTransactional statements in real-worldDeleteUpdateBank to withdraw moneyInterpreting error messagesMSG 547, Level A, state 0, line 11The INSERT
TRY ... Catch is an impressive new feature of SQL Server 2005/2008. Improved developer exception handling. There is no reason not to try. Catch function.
* TRY block-Contains code or script that may produce an exception* Catch Block-If an exception
Introduction:
In the previous article we examined how to let the TableAdapters Wizard automatically create stored procedures. In this article, we'll look at how to get TableAdapter to use existing stored procedures. Because the Northwind database
Change and deletion in 1.Oracle
DML (Data manipulation language– ) can be performed under the following conditions: Inserting data into a table, modifying existing data, and deleting existing data.
A transaction consists of a DML statement that
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.