For faster navigation, this Iframe is preloading the Wikiwand page for CHECK制約.

CHECK制約

この記事は検証可能参考文献や出典が全く示されていないか、不十分です。 出典を追加して記事の信頼性向上にご協力ください。(このテンプレートの使い方)出典検索?"CHECK制約" – ニュース · 書籍 · スカラー · CiNii · J-STAGE · NDL · dlib.jp · ジャパンサーチ · TWL (2023年11月)

CHECK制約(チェックせいやく、: Check Constraint)とは、データベースにおいてデータを追加、更新する際の有効なデータを定義する規則のことをいう。チェック制約はテーブルの1つの列に複数つけることができ、条件に合う(True)かもしくは合わない(False)のいずれかの値を取るでなければならない。

例えば、「製品」を含むデータベースにおいて、製品の価格と数量はゼロもしくは正の値であるというチェック制約を設けることができる。

PRICE >= 0

QUANTITY >= 0

もしこの制約がない場合は、価格がマイナス30ドルとかマイナス3個の数量といったことが可能になってしまう。

チェック制約はデータの有効性と保全性を確保するために利用され、この制約をデータベースレベルで行うことで、たとえアプリケーションが無効なデータを認めたとしても、データベースにその無効データを追加したり、有効なデータを無効なデータに変更したりすることができなくなる。

構文

[編集]

 テーブル作成の際に、以下のように対象となる列にCHECKを記述し、条件式を括弧の中に記述する。ALTER TABLE ステートメントを使うこともできる。

CREATE TABLE テーブル名 (列名1 列データ型1 CHECK(条件式), 列名2 列データ型2,・・・);

外部リンク

[編集]

DB2のCHECK制約

{{bottomLinkPreText}} {{bottomLinkText}}
CHECK制約
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?