Alibabacloud.com offers a wide variety of articles about m a transactions database, easily find your m a transactions database information here online.
In actual projects, we often encounter the need to execute multiple SQL statements in batches to implement database transactions!
Next, we will execute multiple SQL statements in batches to implement database transactions.Code: The two methods are as follows:
-------- Method 1 -------------
///
-------------------------- method 2 -----------------------
simulates three libraries (in the same instance), namely DB1, DB2, DB3The business of the whole transaction is as follows: 1, DB1 write table Data 2, DB2 write table Data 3, DB3 Call stored procedure write table Data 4, each write table data interval simulate throw exception flow, see if data rollbackThe code is as follows:BEGIN TRY BEGIN TRAN INSERT into DB1. dbo. Log ( Type, Message, Stack, Created ) VALUES ( 0, --Type-int N ' Message ', --Message-nvarchar (+) N ' Stack ', --Stack
XA transaction support is limited to INNODB storage engines.
MySQL XA implementations are for external XA, where the MySQL server acts as a resource manager, and the client program acts as the transaction manager. "Internal XA" is not implemented. This allows a separate storage engine within the MySQL server as RM (Resource Manager) and the server itself as a TM
100 yuan remaining in his Beijing account, then he used an ATM to call his Beijing account 1000. When prompted to confirm the submission, he used his mobile phone to check that his account balance was actually 1100.
Exceptions in concurrent database operations-repeated read is not allowed
Set the database isolation level:
SetTRANSACTION isolation level readcommitted; business scenario:
Michael used his
Student After insert As Update Student set sname= ' oooo ' where sid= (select inserted. SID from Inserted) Insert INTO Student select ' Moyao ', ' 1989-11-15 ', ' Male ' SELECT * FROM Student Where the inserted table is a temporary table Stores the information that will be inserted The purpose of this trigger is to check if the information to be inserted conforms to the specified (There are no special records in the product table) This is an example
delimiter//CREATE PROCEDURE P4 (out status int) BEGIN --1. Declares that {set status = 1 is executed if an exception occurs; Rollback ---}--Start transaction--minus 100 from fought account--Fang Shaowei account plus 90--Zhanggen account plus 10 Commit --End Set status = 2; END//delimiter; #实现delimiter//create PROCEDURE P5 (out P_return_code tinyint) BEGIN DECLARE exit Handl Er for SqlException BEGIN--ERROR set p
Properties of database Transactions-acid
1, database Transaction Properties-acid (the first letter of four English words):
1) Atomic sex (atomicity)
So-called atomicity is the operation of a group of operations as an atomic operation, that is either all executed or not.
2) Consistency (consistency)
The consistency of
One, in the transaction a thread (transaction), B thread
① the same connection operation is the same table, if the A-thread operation is rolled back, the operation of the B-thread is also rolled back
② the same connection operation two different tables, if the operation of a thread is rolled back, the operation of the B thread will also be rolled back
③ two diffe
structured as follows:3. Concrete implementation of 3.1 Ishedulerjob3.2 Job3.3SchedulerConfiguration3.4Scheduler3.5 Viewer4. OptimizationA. Two transactions are related to the database of the majority of the deletion and modification, in order to ensure the uniqueness of the data, the database operations to take a tra
foreign key index !!!)?
Reply content:
The situation is as follows:
TableId int (11)
Table BA_id int (11)
The a_id of Table B is the foreign key of Table A's primary key.
----------- The dividing line of all evil ------------
I enabledmysqlAnd then insert a data entry toTable(Hereinafter referred toOperation 1), And then insert the dataTable B(Hereinafter referred toOperation 2).
Operation 2 depends on the ID returned after operation 1 is successf
Beginners of software development are not very familiar with stored procedures and transactions. Today, we will give you a simple example of a transaction, so that you can understand it first. Then we will explain the stored procedure to you.
Start transaction: Begin transaction
Commit transaction: commit transaction
Rollback transaction: rollback transaction
Exa
In the development of Android applications, transaction processing is very important when using a database. first Android database operations (especially write operations) are very slow, and packing all operations into one transaction can greatly improve processing speed. is followed by ensuring that data is consistent so that all operations in one
Transactions: More of a processing mechanism (die)Transactions are for additions and deletions (because they change the data)A transaction is composed of multiple SQL statements for multiple statements, and the overall executionThe 4 characteristics of a transaction are call
In the MVC framework, most departments in some PHP frameworks are a table corresponding to an M file. Suddenly, I wonder how it works if there is a transaction? In the MVC framework, most departments in some PHP frameworks are a table corresponding to an M file. Suddenly, I wonder how it works if there is a transaction
Features of the transaction:1) atomicity (atomicity): A transaction is a logical unit of work for a database, and it must be an atomic unit of work, either fully executed or not executed for its data modification.2) Consistency (consistency): When a transaction is complete,
Features of the transaction:1) atomicity (atomicity): A transaction is a logical unit of work for a database, and it must be an atomic unit of work, either fully executed or not executed for its data modification.2) Consistency (consistency): When a transaction is complete,
transaction cannot be disturbed by other transactions, that is, the internal operation of one transaction and the data used are isolated from other concurrent transactions, and cannot interfere with each other in concurrently executing transactions. (4) Persistence (durability) Persistence is the fact that once a tran
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.