Adding a NOT NULL column?

Поиск
Список
Период
Сортировка
От Philip Molter
Тема Adding a NOT NULL column?
Дата
Msg-id 20010626113759.D12723@datafoundry.net
обсуждение исходный текст
Список pgsql-general
So I can add a column like:

  ALTER TABLE t ADD c SMALLINT

and I can then set it's default value like:

  ALTER TABLE t ALTER c SET DEFAULT 0

but how do set that new column to be NOT NULL?  The postgres docs say
do something like:

  ALTER TABLE t ADD (table constraint definition)

so I would do that like:

  ALTER TABLE ADD c NOT NULL
  ALTER TABLE ADD CONSTRAINT c NOT NULL

each time it fails on the 'NOT'.  How do I add that constraint?

* Philip Molter
* DataFoundry.net
* http://www.datafoundry.net/
* philip@datafoundry.net

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

Предыдущее
От: Tony Grant
Дата:
Сообщение: Re: More Red Hat information
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: More Red Hat information