Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 33A2263276A for ; Thu, 14 May 2009 15:33:47 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 45585-08 for ; Thu, 14 May 2009 15:33:46 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from perseverance.services.encs.concordia.ca (perseverance-96.encs.concordia.ca [132.205.96.94]) by mail.postgresql.org (Postfix) with ESMTP id 22E346326FC for ; Thu, 14 May 2009 15:33:46 -0300 (ADT) Received: from cacao.encs.concordia.ca (emilu@cacao.encs.concordia.ca [132.205.47.225]) by perseverance.services.encs.concordia.ca (envelope-from emilu@encs.concordia.ca) (8.13.7/8.13.7) with ESMTP id n4EIXfQC018286; Thu, 14 May 2009 14:33:42 -0400 Message-ID: <4A0C6405.20609@encs.concordia.ca> Date: Thu, 14 May 2009 14:33:41 -0400 From: Emi Lu Reply-To: emilu@encs.concordia.ca User-Agent: Thunderbird 2.0.0.21 (X11/20090302) MIME-Version: 1.0 To: pgsql-sql@postgresql.org CC: =?UTF-8?B?TWFyY2luIFN0xJlwbmlja2k=?= Subject: Re: alter column from varchar(32) to varchar(255) without view re-creation References: <49A411D6.8080909@encs.concordia.ca> <179149fe0902240809x2ee73eacy3b684d3761b04b03@mail.gmail.com> <49C25CAA.409@encs.concordia.ca> In-Reply-To: <49C25CAA.409@encs.concordia.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.58 on perseverance.encs.concordia.ca at 2009/05/14 14:33:42 EDT X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/69 X-Sequence-Number: 32561 Emi Lu wrote: >>> 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'; Tried this, it worked for table but not view. E.g., ==================================================== T1(col1 varchar(64)... ); create view v1 as select * from T1; update pg_attribute set atttypmod = 4+ 128 where .... \d T1 col1 varchar(128) ============== [OK] \d v1 col1 varchar(64) ============== [did not change?] So, it does not really update all dependencies? Thanks a lot! -- Lu Ying