Re: Changing column question.. - Mailing list pgsql-general

From Neil Conway
Subject Re: Changing column question..
Date
Msg-id 1040333814.13723.4.camel@tokyo
Whole thread Raw
In response to Changing column question..  ("Williams, Travis L, NPONS" <tlw@att.com>)
Responses Re: Changing column question..  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: "Williams, Travis L, NPONS"
Date:
Subject: Changing column question..
Next
From: "scott.marlowe"
Date:
Subject: Re: trouble caused by change in 7.3 handling of '' in