Re: alter table

Поиск
Список
Период
Сортировка
От Andrew Sullivan
Тема Re: alter table
Дата
Msg-id 20011130144245.G4560@mail.libertyrms.com
обсуждение исходный текст
Ответ на Re: alter table  ("Gregory Wood" <gregw@com-stock.com>)
Список 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@libertyrms.info>                              M6K 3E3
                                         +1 416 646 3304 x110


В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Initdb failure with PG 7.1.3 on RH 7.1...
Следующее
От: Francisco Reyes
Дата:
Сообщение: Re: Timing a query