0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Transactionとは

0
Last updated at Posted at 2022-07-08

Transaction(Tx)

  1. データベースのロジック単位で、それ以上分離できない作業の最小単位

  2. insert、update、selectコマンドなどがTx

  3. 主要特徴(ACID)
    (1) 原子性(Atomicity):複数の作業を1つの作業のように動作させる必要がある。
                Txに関連することは、すべて実行されるか、すべて実行されないかの
                1つ。All or nothingという。
    (2) 一貫性(Consistency):Txは実行の前後に一貫した状態を維持する。
    (3) 孤立性(Isolation):各Txは独立的に実行する。記事の最後にIsolation levelについて記述。
    (4) 永続性(Durability):成功したTxの結果は維持されなければならない。



  • Isolation level (各Txを分離させる程度)
    (1) Read uncommited:Commitされていないデータも読み取り可能。
               ①最初の作業、Tx1完了後Commit
               ②2番目の作業、Tx2完了後はUncommit
               ③この状態でTx1からデータを読み込むと、Tx2作業のデータも表示される
    (2) Read commited:Commitされたデータのみ読み取り可能。
    (3) Repeatable read:Txが開始されてからの変更は無視される。
              CommitされたTx1以降CommitされたTx2はTx1に影響を与えられない。
              孤立性の定義と一致するので、Repeatable readがDefault。
    (4) Serializable:1度に1つのTxのみ独立して実行することで、孤立性が最も高い。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?