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

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: Marcin Stępnicki <mstepnicki(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: alter column from varchar(32) to varchar(255) without view re-creation
Date: 2009-03-19 14:54:34
Message-ID: 49C25CAA.409@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>> 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';

I am afraid that only admin can do this dictionary change :(

If it does work, would it cause any storage or efficiency problem? Or it
is just permission issues probably?

Thank you,

--
Lu Ying

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message paulo matadr 2009-03-19 17:42:12 Relatorio da composiçao de FKs e PKs
Previous Message Scott Marlowe 2009-03-19 11:17:14 Re: alter table on a large db