RE: Increasing Table Column Size in 7.0 Syntax

From: "Tamsin" <tg_mail(at)bryncadfan(dot)co(dot)uk>
To: <pgsql-general(at)postgresql(dot)org>
Subject: RE: Increasing Table Column Size in 7.0 Syntax
Date: 2000-11-02 09:48:02
Message-ID: NEBBKHBOBMJCHDMGKCNJMECOCFAA.tg_mail@bryncadfan.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This worked for me:

update pg_attribute set atttypmod = 104 where attname = 'column_name' and
attrelid = (select oid from pg_class where relname = 'tablename');

to set 'columnname' in 'tablename' to a size of 100.

Tamsin

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Richard Poole
> Sent: 01 November 2000 18:11
> To: pgsql-general(at)postgresql(dot)org
> Cc: J. Atwood
> Subject: Re: [GENERAL] Increasing Table Column Size in 7.0 Syntax
>
>
> On Wed, Nov 01, 2000 at 12:43:45PM -0500, J. Atwood wrote:
> > Hello,
> >
> > Looking at the docs for pgsql I have only found stuff on
> altering a table
> > for default and renaming a column but nothing on changing the
> size. I want
> > to increase the size of a field from 2048 to 4096.
> >
> > What is the syntax for this?
>
> You mean, e.g., a field declared varchar(2048) and now you'd like it to
> be varchar(4096)?
>
> Short answer: you can't.
>
> Long answer: create a new table with the same columns, except give the
> one you want to change its new size. Then copy all the data across
> from one table to the other, drop the old table, and rename the new
> one to the old one's name. If you have other long fields in that table,
> beware of the 8k limit on the total length of a row - see my post of
> ten minutes ago...
>
> Richard
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Korsgaard 2000-11-02 10:06:05 server protocol used by Postgres
Previous Message Tatsuo Ishii 2000-11-02 09:33:01 Re: Does column header support multibyte character?