Fwd: Inserts with incomplete rows... NOT NULL constraints

Поиск
Список
Период
Сортировка
От Lars Erik Thorsplass
Тема Fwd: Inserts with incomplete rows... NOT NULL constraints
Дата
Msg-id 7eeb33a0408111319791e88a5@mail.gmail.com
обсуждение исходный текст
Ответ на Inserts with incomplete rows... NOT NULL constraints  (Lars Erik Thorsplass <thorsplass@gmail.com>)
Список pgsql-sql
Sorry about that, forgot to send to the list.


---------- Forwarded message ----------
From: Lars Erik Thorsplass <thorsplass@gmail.com>
Date: Wed, 11 Aug 2004 22:18:24 +0200
Subject: Re: [SQL] Inserts with incomplete rows... NOT NULL constraints
To: Peter Eisentraut <peter_e@gmx.net>

> Am Mittwoch, 11. August 2004 14:35 schrieb Lars Erik Thorsplass:
> > I would expect NULL fields not specified in the insert to get NULL
> > inserted automatically. But that fields which are NOT NULL in the
> > table structure gets inserted a NULL value too seems odd.
>
> More accurately, the default value is inserted, which in turn is null if you
> didn't specify one.  You might find it odd that default values that are
> inconsistent with constraints are allowed, but I don't see any reasonable
> alternative.

Thanks for clearing that up. Guess I'll work around my migration
problems with placeholder default values.

I tried another approach at the same time. I tried to alter the tables
that had changed between versions of the sql structure. The problem
with this is that postgres is unable to add a field to a table with a
NOT NULL constraint. You can add a NOT NULL constraint to the field
afterwards but now all records in the table have a NULL value in the
field. So you wont be able to do that until you change all the values.
No default value was specified for the new field. As with the other
approach this might also work if I enter some default values.

Best regards,

L.E.Thorsplass



-- 
L.E.Thorsplass


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

Предыдущее
От: John DeSoi
Дата:
Сообщение: Re: sleep function
Следующее
От: Thomas Seeber
Дата:
Сообщение: Wierd Error on update