2
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.

sqlで直接DBを更新をしないといけない時はトランザクションをかける

Posted at

mysqlの場合


BEGIN;

# 何かしらの更新処理
update users set password = "hogehoge" where id = xx;

COMMIT;
# or rollback
  • 更新処理を流した時に更新された件数が意図した件数かを確認してから COMMITする

Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
  • 処理を取りやめたい(戻したい時は)rollbackで戻せる
2
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
2
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?