Changing a table column datatype - Mailing list pgsql-novice

From
Subject Changing a table column datatype
Date
Msg-id Pine.LNX.4.33.0305122006230.3148-100000@perilith.com
Whole thread Raw
Responses Re: Changing a table column datatype
List pgsql-novice
Hello,

This has been asked before, but the responses weren't clear enough
for me to understand.

I have a table `mytable' with an attribute `mycol' of datatype char(4) and
I'd like to change it to varchar(20).  Mycol is populated by two values -
NULLs and four element chars.  What I've tried thusfar:

 db=> ALTER TABLE mytable ADD COLUMN mycol_new VARCHAR(20);
 ALTER TABLE
 db=> INSERT INTO mytable (mycol_new) SELECT mycol FROM mytable;
 ERROR:  ExecInsert: Fail to add null value in not null attribute fqdn

The `fqdn' attribute is another column in mytable.

So is it the case that INSERT doesn't like inserting NULL values?  Is
there another way to do this?

I'm using PostgreSQL 7.3.2.

TIA!

-mt


pgsql-novice by date:

Previous
From: "Juliet May"
Date:
Subject: Storing ole object in postgresql
Next
From: "psql novice"
Date:
Subject: Re: JOINS...