Changing a table column datatype

From: <marshall(at)perilith(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Changing a table column datatype
Date: 2003-05-13 00:18:57
Message-ID: Pine.LNX.4.33.0305122006230.3148-100000@perilith.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message psql novice 2003-05-13 01:04:19 Re: JOINS...
Previous Message Juliet May 2003-05-12 22:12:11 Storing ole object in postgresql