Re: SET NULL / SET NOT NULL

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SET NULL / SET NOT NULL
Date: 2002-02-19 22:50:37
Message-ID: Pine.LNX.4.30.0202191743370.684-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Christopher Kings-Lynne writes:

> I'm hoping to implement SET NULL / SET NOT NULL for 7.3
>
> I've been searching the SQL99 docs but I still can't figure out the syntax
> for it.

There isn't really a syntax for it. SQL only allows you to add table
constraints, not column constraints. A NOT NULL constraint is a shorthand
notation for a CHECK constraint, so to add a NOT NULL constraint you'd
have to recognize CHECK constraints of the form CHECK (col IS NOT NULL)
and handle them specially. To drop NOT NULL constraints, you'd use the
regular ALTER TABLE blah DROP CONSTRAINT foo; where foo is the name of the
NOT NULL constraint. The drawback is that NOT NULL constraints currently
don't have a name stored.

--
Peter Eisentraut peter_e(at)gmx(dot)net

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Warner 2002-02-19 23:11:59 Re: pg_dump: use ALTER TABLE for PKs
Previous Message Stephan Szabo 2002-02-19 22:05:56 Re: pg_dump: use ALTER TABLE for PKs