Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Isolation (database systems)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Non-repeatable reads=== A ''non-repeatable read'' occurs when a transaction retrieves a row twice and that row is updated by another transaction that is committed in between. In this example, transaction 1 retrieves the row with id 1, then transaction 2 updates the row with id 1 and is committed, and finally transaction 1 retrieves the row with id 1 again. At the READ UNCOMMITTED and READ COMMITTED isolation levels, the second SELECT in transaction 1 retrieves the updated row: this is a non-repeatable read. At the REPEATABLE READ and SERIALIZABLE isolation levels, the second SELECT in transaction 1 retrieves the initial row. {| |- ! Transaction 1 ! Transaction 2 |- |<syntaxhighlight lang="sql"> BEGIN; SELECT age FROM users WHERE id = 1; -- retrieves 20 </syntaxhighlight> | |- | |<syntaxhighlight lang="sql"> BEGIN; UPDATE users SET age = 21 WHERE id = 1; COMMIT; </syntaxhighlight> |- |<syntaxhighlight lang="sql"> SELECT age FROM users WHERE id = 1; -- READ UNCOMMITTED retrieves 21 (non-repeatable read) -- READ COMMITTED retrieves 21 (non-repeatable read) -- REPEATABLE READ retrieves 20 (non-repeatable read has been avoided) -- SERIALIZABLE retrieves 20 (non-repeatable read has been avoided) COMMIT; </syntaxhighlight> |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)