Re: alter column from varchar(32) to varchar(255) without view re-creation

From: Marcin Stępnicki <mstepnicki(at)gmail(dot)com>
To: emilu(at)encs(dot)concordia(dot)ca
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: alter column from varchar(32) to varchar(255) without view re-creation
Date: 2009-02-24 16:09:08
Message-ID: 179149fe0902240809x2ee73eacy3b684d3761b04b03@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Feb 24, 2009 at 4:27 PM, Emi Lu <emilu(at)encs(dot)concordia(dot)ca> wrote:
> Good morning,
>
> I am using PostgreSQL 8.0.15.
>
> Is there a way that I can easily alter column type from varchar(32) to
> varchar(255) but do not have to worry about views dependent on it?

You should test it carefully and it is considered a bad practice -
I'll probably get sued for recommending this :-), but you may try:

SELECT * from pg_attribute where attname = 'colname' and attrelid =
(SELECT oid FROM pg_class WHERE relname='_tablename');

UPDATE pg_attribute set atttypmod = 4+_new_length_in_your_case_255
where attrelid = _attrelid_from_above_ and attname = 'colname';

Regards,
Marcin

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Stosberg 2009-02-24 16:19:56 Best practices for geo-spatial city name searches?
Previous Message Emi Lu 2009-02-24 15:27:18 alter column from varchar(32) to varchar(255) without view re-creation