Re: Changing column question..

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: Changing column question..
Дата
Msg-id 1040333814.13723.4.camel@tokyo
обсуждение исходный текст
Ответ на Changing column question..  ("Williams, Travis L, NPONS" <tlw@att.com>)
Ответы Re: Changing column question..  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Thu, 2002-12-19 at 16:07, Williams, Travis L, NPONS wrote:
> I just want to make sure that from what I understand I can not change
> a column type from varchar(20) to text or anything else without
> dropping the table.

No, you don't need to drop the table. You can add a new column of the
type you want to change the existing column two, then move the data from
the old data to the new column (using UPDATE), then drop the old column,
and rename the new column to the name of the old column. This works in
7.3+ (as that's the first version that allowed you to drop columns).

> I want it to insert everything up to 20 chars then drop the rest..

Then call substring() on the value you're inserting to chop it down to
20 chars or less.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC




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

Предыдущее
От: "Williams, Travis L, NPONS"
Дата:
Сообщение: Changing column question..
Следующее
От: "scott.marlowe"
Дата:
Сообщение: Re: trouble caused by change in 7.3 handling of '' in