Re: Not null contraints

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
Cc: "Tamsin" <tg_mail(at)bryncadfan(dot)co(dot)uk>, "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Not null contraints
Date: 2000-10-14 06:02:49
Message-ID: 1860.971503369@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Philip Warner <pjw(at)rhyme(dot)com(dot)au> writes:
> At 00:26 14/10/00 -0400, Tom Lane wrote:
>>> I tried updating pg_attribute & setting attnotnull to 'f' for the field in
>>> question. This seems to have worked. Is it safe?! - is there anything
>>> else I should be aware of?
>>
>> Yup, that should do the trick. Not much magic here...

> Just to confirm - does this mean we have ALTER TABLE ADD CONSTRAINT, but
> not ALTER TABLE DROP CONSTRAINT. If so, should it go on a list somewhere?

No, it just means that NOT NULL constraint is handled via a special
flag attached to the column's pg_attribute entry. More general
constraints are handled with other catalog entries. (I think this
is largely a historical artifact, not necessarily a good idea.)

Another relevant comment is that *removing* a NOT NULL constraint
doesn't pose any risk of creating invalid entries in the table data.
So there's no need to worry about cross-checking.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Philip Warner 2000-10-14 06:18:39 Re: Question about pg_dump
Previous Message Michael Engelhart 2000-10-14 05:43:33 Re: config