Re: Changing the type of a column in an already populated - Mailing list pgsql-general

From scott.marlowe
Subject Re: Changing the type of a column in an already populated
Date
Msg-id Pine.LNX.4.33.0211220902330.25220-100000@css120.ihs.com
Whole thread Raw
In response to Re: Changing the type of a column in an already populated database.  (Brian Minton <bminton@efn.org>)
List pgsql-general
On Thu, 21 Nov 2002, Brian Minton wrote:

> David Pradier wrote:
> > Hi!
> >
> > I'd like to know if it is possible to change the type of a column to a
> > compatible one, in an already populated database.
> > For example, changing a column from varchar(20) to varchar(25) ?
> > I'm using postgresql 7.3rc1
> >
> > Thanks for your help.
> >
> > Best regards,
> > David
>
> dump the database, edit the dump file, and reload.  of course, this is
> annonying on live data, but it works

The other method, which works well on tables with no triggers or fks or
anything, which is common when you're first building tables and such:

create table test (name varchar(20), id int, bucks numeric(12,2));
(insert some data, play around...)
begin;
select name::varchar(32), id, bucks into test2 from test;
drop table test;
alter table test2 rename to test;
commit;




pgsql-general by date:

Previous
From: Brandon Craig Rhodes
Date:
Subject: Re: improving a badly optimized query
Next
From: Don Isgitt
Date:
Subject: Re: Lack of use of indexes