Transaction isolation level for database review

One, three paradigms

Second, the programming of sql statement

Third, the underlying implementation of the index

Compound index, index failure condition, optimize index query according to explain, and build appropriate index according to several SQL statements.

4. Features and differences of storage engine: innodb, mylsam,mermory, etc.

Five, transaction related and locking mechanism

Isolation levels and implementation principles, possible problems, use.

6. The principle of master-slave replication, the idea of ​​separation of reading and writing

7. Database optimization (including but not limited to database field design, structure design, SQL optimization, index optimization, etc.)

Eight, sql injection

Transaction isolation level
1. Lost data
Reason: Two transactions T1 and T2 modify data at the same time, and the result submitted by T2 overwrites the result submitted by T1.
For example, the original bank account is 100 yuan, T1, T2 read 100 yuan at the same time, T1 increases 50 yuan, T2 withdraws 30 yuan, the correct result should be 120 yuan left. T2 overwrites the results of T1, and the account only has 70 yuan left.
Solution: Exclusive lock (X lock), the object can only have one exclusive lock. T1 locks the object during the operation, and T2 fails to acquire the lock. When T1 completes the transaction, after releasing the lock, T2 acquires the lock on the object.

Transaction T1 Transaction T2
Acquire A's X lock
read the value of A Acquire A's X lock

2. Dirty read and write X lock is used when reading
and writing data, but no lock is required when reading.
For example, transaction
1, T1 acquires the X lock of bank account A, reads the value 100
2, modifies the value of A to 120, during this period T2 reads the value of A to 120.
3. Rollback A is restored to 100 and release A's X lock
4. The 120 read by T2 is dirty data.

3. Non-repeatable reading

4. Phantom reading

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325855251&siteId=291194637