Database transaction isolation level?

Dirty read: one transaction A modifies or adds a piece of data, which is read by another transaction B before a commits. If A is rolled back, dirty reads may cause B to manipulate data that does not exist.

Unrepeatable read: (select count(*) from user where name= ‘alex’); (select count(*) from user where name= ‘alex’)

Transaction A (select id from user); transaction A (select id from user); If transaction A wants to add a new entry with id 3 to the user table, it will be unable to insert it and send a message to dumplicate entry 3 for key ID if the id is unique.

Database transaction isolation level

When the company paid the salary, the leader sent 20,000 yuan to Liao Zhiwei’s account, but the transaction was not committed. Liao Zhiwei just went to check the account and found that the salary had been delivered to the account, and it was 20,000 yuan. He was very happy. But unfortunately, the leader found that the salary was not correct, which was 16000 yuan, so he quickly changed the amount and submitted the transaction. Finally, Liao Zhiwei’s actual salary was only 16000 yuan, which was a disappointment for Liao Zhiwei.

There are two concurrent transactions, “transaction A: the leader pays Liao Zhiwei salary” and “transaction B: Liao Zhiwei queries the salary account”. Transaction B reads the data that has not been submitted by transaction A. When the isolation level is set to Read uncommitted, dirty reads can occur. How can I avoid dirty reads