Changing a table column datatype

Поиск
Список
Период
Сортировка
От
Тема Changing a table column datatype
Дата
Msg-id Pine.LNX.4.33.0305122006230.3148-100000@perilith.com
обсуждение исходный текст
Ответы Re: Changing a table column datatype  (Oliver Elphick <olly@lfix.co.uk>)
Список 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 по дате отправления:

Предыдущее
От: "Juliet May"
Дата:
Сообщение: Storing ole object in postgresql
Следующее
От: "psql novice"
Дата:
Сообщение: Re: JOINS...