Skip to Content
初めてのSQL 第3版
book

初めてのSQL 第3版

by Alan Beaulieu, 株式会社クイープ
July 2021
Intermediate to advanced
376 pages
6h 34m
Japanese
O'Reilly Japan, Inc.
Content preview from 初めてのSQL 第3版

12章トランザクション

本書のここまでの例はすべて単体の独立したSQL文でした。臨時の報告書の作成やデータメンテナンススクリプトではあたりまえのことかもしれませんが、アプリケーションのロジックには、1つの論理的な作業単位としてまとめて実行しなければならない複数のSQL文が含まれていることがよくあります。そこで本章では、トランザクション(transaction)に着目します。トランザクションは複数のSQL文をグループ化するためのメカニズムであり、それらの文はすべて成功するかすべて失敗するかのどちらかになります。

12.1 マルチユーザーデータベース

データベース管理システム(DBMS)では、1人のユーザーがクエリを実行したりデータを変更したりできますが、最近では、数千人もの人々が同時にデータベースに変更を加えることがあります。業務時間中のデータウェアハウスのように、すべてのユーザーがクエリを実行するだけであるとしたら、データベースサーバーが対処しなければならない問題は数えるほどしかありません。しかし、一部のユーザーがデータの追加や変更を行うとしたら、データベースサーバーが対処しなければならない問題は一気に増えることになります。

たとえば、今週のレンタル状況をまとめたレポートを作成しているとしましょう。ところが、レポートを作成している最中に次の出来事が発生します。

  • 顧客が映画をレンタルする。
  • 顧客が返却予定日を過ぎてから映画を返却し、延滞料金を支払う。
  • 新しい映画が5本入荷する。

レポートを作成している最中に複数のユーザーがデータベースのデータを変更した場合、レポートに表示する数字はいくつにすべきでしょうか。その答えはデータベースサーバーがロック(lock)をどのように処理するかによって少し変わってきます。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Googleのソフトウェアエンジニアリング ―持続可能なプログラミングを支える技術、文化、プロセス

Googleのソフトウェアエンジニアリング ―持続可能なプログラミングを支える技術、文化、プロセス

Titus Winters, Tom Manshreck, Hyrum Wright, 竹辺 靖昭, 久富木 隆一

Publisher Resources

ISBN: 9784873119588Other