What if some of mysqlsql statements are successfully executed?

Source: Internet
Author: User
1: updatefromtb_testsetmid1whereidin (1, 2, 3 ,......) 2: insertintotb_test (id, mid) values (1, 2), (2, 3), (3, 4 ),(......) I heard that the exclusive lock will be automatically applied during the write operation. In the above case, the lock row is a row lock, and then the last... 1: update from tb_test set mid = 1 where id in(1,2,3,……)
2: insert into tb_test(id,mid) values (1,2), (2,3), (3,4), (……)

I heard that the exclusive lock will be automatically applied during write operations. In this case, the lock row is a row lock, and the lock is released at the same time, that is, a row is locked, and a row is operated until there are no conditions, finally all locks are released simultaneously by http://hedengcheng.com /? P = 771

Do not enable transactions, InnoDB table

Problem 1: If the update/operation fails partially (the update fails due to a primary key or a unique index), but according to the above understanding, the analysis of the write operation, although the final SQL Execution fails, Will some update/Add operations be successful?

Question 2: If SQL is partially executed successfully, "partially activated" may appear as if there is a mysql or pdo configuration. The last time I saw a similar problem here, I seem to have said that, it's just a matter of time.

Reply content:

1:update from tb_test set mid = 1 where id in(1,2,3,……)
2:insert into tb_test(id,mid) values (1,2), (2,3), (3,4), (……)

I heard that the exclusive lock will be automatically applied during write operations. In this case, the lock row is a row lock, and the lock is released at the same time, that is, a row is locked, and a row is operated until there are no conditions, finally all locks are released simultaneously by http://hedengcheng.com /? P = 771

Do not enable transactions, InnoDB table

Problem 1: If the update/operation fails partially (the update fails due to a primary key or a unique index), but according to the above understanding, the analysis of the write operation, although the final SQL Execution fails, Will some update/Add operations be successful?

Question 2: If SQL is partially executed successfully, "partially activated" may appear as if there is a mysql or pdo configuration. The last time I saw a similar problem here, I seem to have said that, it's just a matter of time.

Thank you for inviting me to sort out some previous answers for your reference.
Locking sequence of mysql INNODB update statements
In high concurrency scenarios, when an insert update delete operation is performed on a table, what happens if the update fails?

For the problem of the subject, you can clearly tell you that some successes will not occur.
A single-row statement is also a transaction and won't be half successful.

Nobody knows this?

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.