Re: INSERT with SELECT not working in pgAdmin - Mailing list pgsql-general

From Dmitriy Igrishin
Subject Re: INSERT with SELECT not working in pgAdmin
Date
Msg-id AANLkTimwT4uie_kqCxQsODY=TCPv+d0+wzd2wtCQeasZ@mail.gmail.com
Whole thread Raw
In response to Re: INSERT with SELECT not working in pgAdmin  (Stefan Wild <wilds81@yahoo.de>)
List pgsql-general
Hey Stefan,

For surrogate keys there is no reason to calculate values manually.
You should use sequences instead. Please, see
http://www.postgresql.org/docs/8.3/static/sql-createsequence.html
You may also use a SERIAL data type which creates a sequence
for you automatically upon its creation. Please, see
http://www.postgresql.org/docs/8.3/static/datatype-numeric.html#DATATYPE-SERIAL
Since you execute INSERT command without specifying an "id" column,
and there is no default value for it, then the default is NULL. So, you need
to define a default and the best solution to define it as next value of sequence.

--
Regards,
Dmitriy


pgsql-general by date:

Previous
From: Stefan Wild
Date:
Subject: Re: INSERT with SELECT not working in pgAdmin
Next
From: "Rhys A.D. Stewart"
Date:
Subject: versioned pl/pgsql functions