Re: Need to change the size of a field

From: "Nick Fankhauser" <nickf(at)ontko(dot)com>
To: <suresh(at)mithi(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Need to change the size of a field
Date: 2002-02-18 13:56:14
Message-ID: NEBBLAAHGLEEPCGOBHDGMEPNEFAA.nickf@ontko.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I don't think you can alter a column in the current version, but here's an
example of a workaround that should do the job:

create table change_me (id int, text varchar(20));

[Then I add some data & decide I need to widen the text field without losing
the data.]

create table temp_change_me as select * from change_me;

drop table change_me;

create table change_me (id int, text varchar(50));

insert into change_me (id, text) (select id, text from temp_change_me);

drop table temp_change_me;

hth, Nick

> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org
> [mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of suresh(at)mithi(dot)com
> Sent: Monday, February 18, 2002 8:31 AM
> To: pgsql-sql(at)postgresql(dot)org
> Subject: [SQL] Need to change the size of a field
>
>
> Hi
>
> I have a table with one of the fields as a varchar(32) field.
> This table has
> about 100,000 records.
> I want to increase the size of the varchar field to 64. How can
> this be done
> without affecting the data already present ?
> Thanx in advance.
> regards
> suresh
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message postgresql 2002-02-18 14:23:54 Re: Need to change the size of a field
Previous Message suresh 2002-02-18 13:30:49 Need to change the size of a field