From 61d81bd28dbec65a6b144e0cd3d0bfe25913c3ac Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 5 Dec 2011 15:10:18 -0300 Subject: Allow CHECK constraints to be declared ONLY This makes them enforceable only on the parent table, not on children tables. This is useful in various situations, per discussion involving people bitten by the restrictive behavior introduced in 8.4. Message-Id: 8762mp93iw.fsf@comcast.net CAFaPBrSMMpubkGf4zcRL_YL-AERUbYF_-ZNNYfb3CVwwEqc9TQ@mail.gmail.com Authors: Nikhil Sontakke, Alex Hunsaker Reviewed by Robert Haas and myself --- doc/src/sgml/catalogs.sgml | 10 ++++++++++ doc/src/sgml/ref/alter_table.sgml | 8 ++++++++ 2 files changed, 18 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index d948ed487c6..be4bbc736c7 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -2036,6 +2036,16 @@ + + conisonly + bool + + + This constraint is defined locally for the relation. It is a + non-inheritable constraint. + + + conkey int2[] diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 00a477ef885..3b111a4c2b9 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -983,6 +983,14 @@ ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5); + + To add a check constraint only to a table and not to its children: + +ALTER TABLE ONLY distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5); + + (The check constraint will not be inherited by future children, either.) + + To remove a check constraint from a table and all its children: -- cgit v1.2.3