Re: Smartest way to resize a column?

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: "Phoenix Kiula" <phoenix(dot)kiula(at)gmail(dot)com>
Cc: "Ian Barwick" <barwick(at)gmail(dot)com>, "PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Smartest way to resize a column?
Date: 2009-01-12 01:43:42
Message-ID: 200901111743.42826.aklaver@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sunday 11 January 2009 5:21:46 pm Phoenix Kiula wrote:
> On Mon, Jan 12, 2009 at 9:12 AM, Ian Barwick <barwick(at)gmail(dot)com> wrote:
> > 2009/1/12 Phoenix Kiula <phoenix(dot)kiula(at)gmail(dot)com>:
> >> I am trying to resize a column on a large-ish database (with 5 million
> >> rows).
> >
> > ALTER TABLE users ALTER COLUMN name TYPE VARCHAR(35)
> >
> > HTH
>
> Thanks! I guess I was missing the word "TYPE". This won't affect my
> "not null" on the column right?
>
> Also, is there a safe and fast way of doing this on a live database,
> without bringing it down if possible? This is an indexed column so I
> wonder if that will slow up the process quite a bit?

From the fine manual:
http://www.postgresql.org/docs/8.3/interactive/sql-altertable.html

"Adding a column with a non-null default or changing the type of an existing
column will require the entire table to be rewritten. This might take a
significant amount of time for a large table; and it will temporarily require
double the disk space."

--
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2009-01-12 02:16:51 Re: Unexpected behavior from psql
Previous Message Phoenix Kiula 2009-01-12 01:21:46 Re: Smartest way to resize a column?