Re: Importing data

Lists: pgsql-general
From: Patrick Nelson <pnelson(at)neatech(dot)com>
To: "PostgreSQL List (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Importing data
Date: 2002-07-29 19:32:53
Message-ID: 4165C48DE9A0D211B6400800095C585F172DE9@WASHINGTON
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

nconway(at)klamath(dot)dyndns(dot)org wrote:
----------------->>>>
If data for an attribute is missing, it will be set to NULL in 7.2 and
earlier versions of PostgreSQL. This behavior will be fixed in 7.3, but
until then, you can set the "id" column yourself:

COPY ...;
UPDATE mss SET id = nextval('mss_id_seq');
----------------->>>>
Wow, thanks that helps a lot. Maybe you can help shed some light. How do
you add a column and make it not null? I want to add a column the is:

NOT NULL DEFAULT nextval('mss_id_seq'::text)

Tried the following:

ALTER TABLE mss ADD COLUMN id int4 NOT NULL;
ALTER TABLE mss ALTER COLUMN id SET DEFAULT nextval('mss_id_seq'::text);

But it doesn't set the column modifier to NOT NULL. Why?


From: Andrew Sullivan <andrew(at)libertyrms(dot)info>
To: "PostgreSQL List (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Importing data
Date: 2002-07-29 20:24:54
Message-ID: 20020729162454.T13977@mail.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Mon, Jul 29, 2002 at 12:32:53PM -0700, Patrick Nelson wrote:
> Tried the following:
>
> ALTER TABLE mss ADD COLUMN id int4 NOT NULL;
> ALTER TABLE mss ALTER COLUMN id SET DEFAULT nextval('mss_id_seq'::text);
>
> But it doesn't set the column modifier to NOT NULL. Why?

You should get an error in 7.2.x; it fails silently in 7.1. It's not
implemented yet. You can make it happen, however, by setting a
CHECK NOT NULL constraint on the column.

A

--
----
Andrew Sullivan 87 Mowat Avenue
Liberty RMS Toronto, Ontario Canada
<andrew(at)libertyrms(dot)info> M6K 3E3
+1 416 646 3304 x110