Help Center > > Developer Guide> Data Import> Managing Concurrent Write Operations> Concurrent INSERT and DELETE in the Same Table

Concurrent INSERT and DELETE in the Same Table

Updated at: Mar 13, 2020 GMT+08:00

Transaction T1:

1
2
3
START TRANSACTION;
INSERT INTO test VALUES(1,'test1','test123');
COMMIT;

Transaction T2:

1
2
3
START TRANSACTION;
DELETE test WHERE NAME='test1';
COMMIT;

Scenario 1:

T1 is started but not committed. At the same time, T2 is started. After the INSERT of T1 is complete, the DELETE of T2 is performed. In this case, DELETE 0 is displayed, because T1 is not committed and T2 cannot see the data inserted by T1.

Scenario 2:

  • READ COMMITTED level

    T1 is started but not committed. At the same time, T2 is started. After the INSERT of T1 is complete, T1 is committed and the DELETE of T2 is performed. In this case, DELETE 1 is displayed, because T2 can see the data inserted by T1.

  • REPEATABLE READ level

    T1 is started but not committed. At the same time, T2 is started. After the INSERT of T1 is complete, T1 is committed and the DELETE of T2 is performed. In this case, DELETE 0 is displayed, because the data obtained in queries is consistent in a transaction.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel