Re: changing column data types

Поиск
Список
Период
Сортировка
От ERIC Lawson - x52010
Тема Re: changing column data types
Дата
Msg-id Pine.LNX.4.21.0102210825220.32522-100000@arwen.bioeng.washington.edu
обсуждение исходный текст
Ответ на changing column data types  ("Derek" <derek.mailer@virgin.net>)
Список pgsql-novice
What command did psql complain about, and what was psql's complaint
(supposing you're using psql)?

The general procedure, AFAIK, if you don't care about getting rid of the
old column, is to use ALTER TABLE tablename ADD COLUMN columnname
DATATYPE, then UPDATE tablename SET newcolumn=oldcolumn WHERE whatever,
'casting' the data from the old column as needed and appropriate.

This seems comparatively painless to me.  It gets more painful when the
lack of an ALTER TABLE tablename DROP COLUMN columnname is felt, but even
then, using pg_dump -s along with a text editor ain't no more than a
mosquito bite.

On Wed, 21 Feb 2001, Derek wrote:

> Excuse my ignorance, but I'm used to MySQL and I'm having problems trying to
> convert a few columns from varchar to numeric.  I attempted to get around
> the problem by creating a new numeric column, but pgsql didn't like it when
> I tried to copy the varchar column info into the numeric one.
>
> Is there a painless way of changing a column type?
>
> Thanks in advance for any help offered
>
> Derek
>

--

James Eric Lawson
Research Publications Editor III
National Simulation Resource

eric@bioeng.washington.edu

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Everyday language is a part of the human organism and is no less
complicated than it. - Ludwig Wittgenstein (1889-1951) [Tractatus
Logico-Philosophicus, 1921]



В списке pgsql-novice по дате отправления:

Предыдущее
От: "Derek"
Дата:
Сообщение: changing column data types
Следующее
От: ERIC Lawson - x52010
Дата:
Сообщение: Re: copying tables