Re: Change the behaviour of the SERIAL "Type"

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Change the behaviour of the SERIAL "Type"
Дата
Msg-id 20030626124929.GA7040@wolff.to
обсуждение исходный текст
Ответ на Change the behaviour of the SERIAL "Type"  (Dani Oderbolz <oderbolz@ecologic.de>)
Ответы Re: Change the behaviour of the SERIAL "Type"  (Randall Lucas <rlucas@tercent.net>)
Список pgsql-sql
On Thu, Jun 26, 2003 at 14:31:34 +0200, Dani Oderbolz <oderbolz@ecologic.de> wrote:
> 
> It was written for MySQL, which can take NULL and then assign an 
> auto_increment.
> However, in PostgreSQL I am getting problems, because it would not let 
> me insert NULL
> into a NOT NULL column (which is perfectly sensible from my point of view).
> But as the author has also left out the column list in the insert, its 
> really tedious to change
> the code.

You can use the keyword DEFAULT instead of NULL and it will do what you
want.

> This way, there would be no possibility to circumvent the Value which 
> comes from the Sequence.

You can use a unique constraint to enforce uniqueness.

> Is there a way to change SERIAL this way?

Well you can certainly write your own trigger to do this.


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

Предыдущее
От: Dani Oderbolz
Дата:
Сообщение: Change the behaviour of the SERIAL "Type"
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Join or Where?