Re: alter table

From: Andrew Sullivan <andrew(at)libertyrms(dot)info>
To: PostgreSQL general list <pgsql-general(at)postgresql(dot)org>
Subject: Re: alter table
Date: 2001-11-30 19:42:45
Message-ID: 20011130144245.G4560@mail.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Nov 30, 2001 at 11:44:12AM -0500, Gregory Wood wrote:
> According to the documentation:
>
> ALTER TABLE table [ * ] ADD [ COLUMN ] column type

[. . .]

> You'll no doubt also want to add that NOT NULL constraint:
>
> ALTER TABLE table ADD table constraint definition
>
> I know this only because it bit me in the ass the other day too :)

Also according to the documentation:

----

In the current implementation, default and constraint clauses for
the new column will be ignored. You can use the SET DEFAULT form of
ALTER TABLE to set the default later. (You will also have to update
the already existing rows to the new default value, using UPDATE.)

In the current implementation, only FOREIGN KEY constraints can be
added to a table. To create or remove a unique constraint, create a
unique index (see CREATE INDEX). To add check constraints you need to
recreate and reload the table, using other parameters to the CREATE
TABLE command.
----

So you can't add a NOT NULL constraint. There's a handy ip on
techdocs, though (written by someone else) as to how to change things
to enfoce NOT NULL.

A

--
----
Andrew Sullivan 87 Mowat Avenue
Liberty RMS Toronto, Ontario Canada
<andrew(at)libertyrms(dot)info> M6K 3E3
+1 416 646 3304 x110

In response to

Browse pgsql-general by date

  From Date Subject
Next Message sara_software 2001-11-30 21:32:39 function from rule
Previous Message Tom Lane 2001-11-30 19:36:14 Re: Initdb failure with PG 7.1.3 on RH 7.1...