What is the difference between Non-Repeatable Read and Phantom Read?
In database systems, Non-Repeatable Read (NR) and Phantom Read (PR) are isolation level issues that can occur when multiple transactions are accessing the same data concurrently. Non-Repeatable Read (NR) occurs when a transaction reads a row multiple times and receives different data each time. This can happen when another transaction updates or deletes the same row that is being read by the first transaction. This means that a transaction may read the same row more than once and get different data, causing the transaction to produce inconsistent results.

Phantom Read (PR) occurs when a transaction reads a set of rows multiple times and receives different data sets each time. This can happen when another transaction inserts or deletes rows in the same table or index read by the first transaction. This means that a transaction may read the same set of rows more than once and get different data, causing the transaction to produce inconsistent results.

In summary, NR occurs when a transaction reads a row and gets different values, while PR occurs when a transaction reads a set of rows and gets different sets of rows. NR and PR are both isolation-level issues that can occur in a database system when multiple transactions are accessing the same data concurrently, but they are different types of problems.