#author("2020-07-12T22:24:03+09:00","default:ryuichi","ryuichi")
#author("2020-07-13T20:04:04+09:00","default:ryuichi","ryuichi")
* CHECK制約 [#ec240373]


 CREATE TABLE t1 ( gender TEXT CHECK ( gender IN ( 'man', 'woman' ) ) );
   => genderカラムにCHECK制約を設定
  
 INSERT INTO t1 VALUES ( 'man' );
   => OK
 
 INSERT INTO t1 VALUES ( 'woman' );
   => OK
 
 INSERT INTO t1 VALUES ( 'foo' );
 ERROR:  new row for relation "t1" violates check constraint "t1_gender_check"
 DETAIL:  Failing row contains (foo).

** テーブル定義 [#k81f8029]
   テーブル "public.t1"
    列   |  型  | 修飾語
 --------+------+--------
  gender | text |
 検査制約:
     "t1_gender_check" CHECK (gender = ANY (ARRAY['man'::text, 'woman'::text]))

** 参考 [#y8ae877c]

https://www.postgresql.jp/document/12/html/ddl-constraints.html#DDL-CONSTRAINTS-CHECK-CONSTRAINTS
https://www.postgresql.org/docs/current/ddl-constraints.html

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS