Re: How do I change column details

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Simon Windsor <simon(dot)windsor(at)cornfield(dot)org(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How do I change column details
Date: 2004-03-10 05:05:39
Message-ID: 20040310050539.GE31629@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Mar 10, 2004 at 00:42:18 +0000,
Simon Windsor <simon(dot)windsor(at)cornfield(dot)org(dot)uk> wrote:
> Hi
>
> I have a MySQL application which I am porting to Postgres. I have been
> asked to increase the size of a varchar column from 200 chars to 2000.
>
> Normally, in MySQL/Oracle this is done with the alter table modify
> column command.
>
> How do I do this in Postgres?
>
> I have just renamed the column, created the new one, copied the data
> into it and dropped the renamed column. Is the only way?

For varchar there is a way to do this by munging the system catalogs.
The method has been described on the list previously and should be in the
archives.

You might consider changing the column type to TEXT so that you don't
have to go through this again. If you really need it limited to keep
the app from barfing, use a constraint. That will be much easier to
update in the future.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-03-10 05:53:55 Re: does this look more like a possible bug or more like a possible hardware problem...? (long)
Previous Message Bruno Wolff III 2004-03-10 03:58:33 Re: Data Corruption in case of abrupt failure