This article will introduce mysql transaction processing and table locking in detail. For more information, see
This article will introduce mysql transaction processing and table locking in detail. For more information, see
There are two main
First, mysqli connections are permanent connections, while mysql does not. What does it mean? Mysql will re-open a new process whenever it is used for the second time, while mysql uses only the same process,
First, mysqli connections are permanent
Transaction processing in various management systems have a wide range of applications, such as personnel management system, many synchronous database operations need to use the transaction processing. For example, in the Personnel Management system,
Autocommit is a change in transaction submission method parameters, set to 1 o'clock, all changes to the immediate effect of the change, that is, 1 o'clock, after the execution of the statement, the transaction automatically submitted. If set to 0 o'
Mysqli encapsulates some advanced operations, such as transactions, while encapsulating many of the methods available during DB operations.
The most widely used place is the mysqli business.
Like the following example:
Copy Code code as
Copy Code code as follows:
mysql_query ("Set autocommit=0");
$list _one = $db->fetch_first ("SELECT * from prizes where id =". $id. " For UPDATE ");
$db->query ("DELETE from prizes WHERE id =". $list _one[' id '));
mysql_query
Objective
In order to ensure consistent integrity of data, there is a locking mechanism in any database. The quality of locking mechanism should be directly thought of the concurrent processing ability and performance of a database system, so the
Start transaction, commit and rollback syntaxStart Transaction | Begin [Work]commit [Work] [and [No] chain] [[No] release]rollback [work] [and [No] chain] [[No] release]set autocommit = { 0 | The 1}start transaction or BEGIN statement can begin a
This article gives you the content is about the MySQL database lock mechanism of the detailed introduction, there is a certain reference value, the need for friends can refer to, I hope you have some help.
Pessimistic lock and optimistic
øfunction functionFunctions are much more useful, and are generally used after the SELECT query statement and the WHERE condition statement. According to the result returned by the function,Can be divided into: multi-line functions and single-line
PHP and MySQL transaction processingIn general, transactions should have acid characteristics. The so-called acid is Atomic (atomicity), consistent (consistency), Isolated (isolation), durable (persistent) four words written in the first letter, the
MySQL autocommit (auto-commit) is on by default, it has a certain impact on MySQL performance, for example, if you insert 1000 data, MySQL will commit1000 times, if we put autocommit off, through the program to control , only one commit is allowed.1.
Requirements Description:Case background: In the course of bank transfer, accidents are unavoidable. To avoid unnecessary losses caused by an accident, the transaction is handled in the same way:A account has an existing balance of $1000 and a
Log into the server[Email protected]_25 ~]# su-mysql[[email protected]_25 ~]$ mysql.localwelcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 126000553Server version:5.5.27-log sourcedistribution Copyright (c) # D,
1. Brief description
we know that the Sqlplus inside Oracle executes DML statements; commit commits are required; if it is wrong, you can roll back the rollback; however, the default is auto-commit in PostgreSQL, and submit it immediately
For MyISAM types of tables, you can quickly import large amounts of data in the following ways:ALTER TABLE tblname DISABLE KEYS;Loading the dataALTER TABLE tblname ENABLE KEYS;These two commands are used to open or close an update for a non-unique
about the lock in MySQLIn a concurrent environment, there is the possibility of dirty reads (Dirty read), non-repeatable reads (unrepeatable read), Phantom reads (Phantom read), update loss (Lost update), etc., so MySQL introduces a lot of lock
First, find slow queryWe talked about the definition of a slow query, which we create a large table for data preparation for slow queries. 2. Slow query data preparationTo find a slow query, you first have to make the slow query happen. A slow query
Mysqli encapsulates some advanced operations, such as transactions, while encapsulating many of the methods available during DB operations.
The most widely used place is the mysqli business.
Like the following example:
The code is as
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.