From: | Lars Erik Thorsplass <thorsplass(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Fwd: Inserts with incomplete rows... NOT NULL constraints |
Date: | 2004-08-11 20:19:30 |
Message-ID: | 7eeb33a0408111319791e88a5@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Sorry about that, forgot to send to the list.
---------- Forwarded message ----------
From: Lars Erik Thorsplass <thorsplass(at)gmail(dot)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(at)gmx(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Seeber | 2004-08-11 20:21:09 | Wierd Error on update |
Previous Message | Gaetano Mendola | 2004-08-11 20:15:51 | Re: Displaying two tables side by side |