Inserts with incomplete rows... NOT NULL constraints

From: Lars Erik Thorsplass <thorsplass(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Inserts with incomplete rows... NOT NULL constraints
Date: 2004-08-11 12:35:32
Message-ID: 7eeb33a040811053563894d7b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Am trying to migrate some old data to a new database schema. I have
dumped the old data as SQL statements. The new datastructure just
contains some added fields to a few tables.

My plan was to just create a new database with the new structure, dump
the content only as SQL insert statements. And just run the statements
contained in the dump on the new database.

The problem am now facing is that postgres will try to insert a NULL
value for fields not specified in the insert query and that are
defined as NOT NULL in the table structure. Is this the correct
behaviour?

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.

Am loosing my mind in this heat but, you should be able to insert just
half the fields of a table record if the datastructure would allow it?
Wouldnt you?

I feel like a such a noob :(

Please advise..

--
L.E.Thorsplass

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2004-08-11 13:02:08 Re: Inserts with incomplete rows... NOT NULL constraints
Previous Message Philippe Lang 2004-08-11 08:24:42 Re: function expression in FROM may not refer to other relations of same query level