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.

TCL commands

0
Last updated at Posted at 2022-08-16

Transaction(Tx)

Transactionについては以前投稿したので簡単に言うと、
データベースの論理演算単位であり、分離できない作業の最小単位のこと。
@Transactional をクラスやメソッドに貼り付ける場合、該当範囲内のメソッドがTxになることを保証してくれる。

TCL(Transaction Control Language)

データベース内のTxを管理するために使用される。このTCLの代表的コマンドが以下の3つ。

  1. COMMIT
    変更されたデータをDBに永続的に保存するために使用。

  2. ROLLBACK
    DBを最後にCommitされた状態に復元するコマンド。Windowsで言うとCtrl+Zのみたいかも。

  3. SAVEPOINT
    Savepointを設定すると、最後のCommit全体をRollbackするのではなく、現時点からSavepointまでのTxだけをRollbackすることができる。

SAVEPOINT SavePoint名; // SavePointの設定
ROLLBACK TO SavePoint名; // SavepointまでRollback
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?