From: | Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> |
---|---|
To: | Karl Stubsjoen <karl(at)azprogolf(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Help changing varchar field |
Date: | 2002-10-17 15:42:11 |
Message-ID: | 1034869331.18814.11.camel@camel |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I normally don't recommend mucking in system tables, but if you want to
do it that way this should work:
select a.* from pg_attribute a, pg_class c where c.relname='tablename'
and a.attnum > 0 and a.attrelid = c.oid;
this should show you the attribute information for the field you want to
modify.
then do
update pg_attribute set atttypmod=19 where attrelid=(select oid from
pg_class where relname='tablename') and attname='fieldname';
you can then run the first query to verify the changes
Robert Treat
On Thu, 2002-10-17 at 11:22, Karl Stubsjoen wrote:
> I'm a postresql newbie, big time. I've been assigned the task of making
> some simple changes to our dealer website. The PO Number field is the first
> request, currently it excepts just 6 characters (do to the varchar(6) type).
> Alvaro: how can this change be implemented? i can get to a postrgesql
> command prompt.
>
> Karl
>
> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Alvaro Herrera
> Munoz
> Sent: Thursday, October 17, 2002 7:46 AM
> To: Robert Treat
> Cc: Karl Stubsjoen; pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Help changing varchar field
>
>
> On Thu, Oct 17, 2002 at 10:33:52AM -0400, Robert Treat wrote:
> > AFAIK there's no easy way to do this. Essentially you'll need to create
> > a new field of varchar(15), copy the contents of varchar(6), drop
> > varchar(6), then rename varchar(15). I'd recommend doing it all in one
> > transaction.
>
> You can also set atttypmod to 15+4 (right now it should be 6+4) to the
> attribute in pg_attribute.
>
> --
> Alvaro Herrera (<alvherre[(at)]dcc(dot)uchile(dot)cl>)
> "La espina, desde que nace, ya pincha" (Proverbio africano)
>
From | Date | Subject | |
---|---|---|---|
Next Message | Shridhar Daithankar | 2002-10-17 15:54:59 | Re: Help normalizing table(s) |
Previous Message | Karl Stubsjoen | 2002-10-17 15:22:45 | Re: Help changing varchar field |