Add for update after the database SELECT query statement

describe :

        What is the function of the for update added after the database SELECT query statement?

effect: 

        Adding "for update" to a SELECT query in the database locks the selected rows, preventing other transactions from modifying them until the lock is released. It is more useful when you need to ensure that a specific set of rows will not be modified by another transaction during processing. (I usually use the data rows of the query table to manually modify the data of the table, and do not use the update statement to modify the set , I find it more convenient to use this way)

Preconditions (restrictions): 

do what :

After using the SELECT SQL statement to query, add for update to manually modify the data in the table.

What are the restrictions on conditions :

It can only be modified for update of a single table, and cannot connect tables/and multi-table operations (note: only single table can be used)

Precautions :

1. When manually modifying the data in the table, click Unlock to modify the data;

2. If the data has been modified, you need to check the data to confirm the modification 

3. The data has been modified, and it has been checked. Click the lock to re-lock the rows of the data table.

4. Finally, submit the database modification table transaction to finally modify the data (if you change the wrong data, you can roll back the transaction at this step, but after the transaction has been submitted, the data cannot be restored, so modify Data backup should be carried out before the data, there may be measures to restore the data)

Guess you like

Origin blog.csdn.net/qq_70095877/article/details/130444470