Rép. : Re: Alter table syntax

From: "Erwan DUROSELLE" <EDuroselle(at)seafrance(dot)fr>
To: <alvherre(at)dcc(dot)uchile(dot)cl>, <garo(at)xapnet(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Rép. : Re: Alter table syntax
Date: 2002-10-23 15:00:58
Message-ID: 1f9f95459d4651ea3982c3dbf783e8063db6bc4d@
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Try:
alter table <tablename> add constraint <whatevername> check ( <fieldname> is not null )

Erwan

>>> Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> 23/10/2002 15:39 >>>
On Tue, Oct 22, 2002 at 11:38:33PM -0700, Garo Hussenjian wrote:
> Hello,
>
> Can anyone remind me how to make a column 'not null' after it is created?

ALTER TABLE ... ADD NOT NULL
But I think this is a 7.3 addition (i.e. not released yet).

If you don't have that, you can try looking up it's pg_attribute tuple
(it was shown here in the last week how to do so, AFAIR) and set to true
its attnotnull.

Be warned that incorrectly modifying system catalogs can lead to massive
data loss! Are you scared already? If so, take all needed precautions
and go ahead. If you don't, start imagining people yelling at you
because of a lost database and start again.

--
Alvaro Herrera (<alvherre[a]atentus.com>)
"La espina, desde que nace, ya pincha" (Proverbio africano)

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Old 2002-10-23 16:39:40 Re: Matching unique primary keys
Previous Message Nicolas Prentzas 2002-10-23 15:00:06 Views + Criteria