Jeroen Ruigrok/asmodai <[EMAIL PROTECTED]> writes:
> just want to verify first with you guys before dumping it on the bugs
> list.  Most likely I am just being silly here or something.

The ALTER ADD CONSTRAINT form creates a table constraint, ie, one that's
not attached to any particular column.  If you write the constraint in
the CREATE TABLE as a table constraint, then you get the same result as
with ALTER ADD CONSTRAINT.

regression=# create table blah (name TEXT, CHECK (name IN ('blah', 'bleh')));
CREATE TABLE
regression=# \d blah
    Table "public.blah"
 Column | Type | Modifiers
--------+------+-----------
 name   | text |
Check constraints:
    "$1" CHECK ((name = 'blah'::text) OR (name = 'bleh'::text))


If you don't like the automatically generated name, assign your own...

regression=# ALTER TABLE blah ADD CONSTRAINT fooey CHECK (name IN ('blah', 'bleh'));
ALTER TABLE
regression=# \d blah
    Table "public.blah"
 Column | Type | Modifiers
--------+------+-----------
 name   | text |
Check constraints:
    "$1" CHECK ((name = 'blah'::text) OR (name = 'bleh'::text))
    "fooey" CHECK ((name = 'blah'::text) OR (name = 'bleh'::text))


                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to