X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id ACC63D1D080 for ; Tue, 13 Apr 2004 12:36:50 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 60104-03 for ; Tue, 13 Apr 2004 12:36:48 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 9F668D1CCB7 for ; Tue, 13 Apr 2004 12:36:47 -0300 (ADT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i3DFYb1p015644; Tue, 13 Apr 2004 09:34:38 -0600 (MDT) Date: Tue, 13 Apr 2004 09:33:51 -0600 (MDT) From: "scott.marlowe" To: Stefan Holzheu Cc: ADMIN Subject: Re: varchar to text In-Reply-To: <407BB7BA.9070103@bitoek.uni-bayreuth.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/201 X-Sequence-Number: 13174 On Tue, 13 Apr 2004, Stefan Holzheu wrote: > I'd like to alter all columns from type varchar to text. Could I do this by: > > UPDATE pg_attribute SET atttypid = 25, atttypmod=-1 where attrelid > =(select oid from pg_class where relname='table_name') and atttypid=1043; > > I just tried on a test database. It worked fine with one exception: > Views depending on an altered column did not work anymore. After > recreating the views it was ok. > > I know the procedure of "rename column - add column - delete column" but > it's laborious for a large number of columns. There was also a > discussion on the list maybe one year ago. Unfortunately I couldn't find > the thread in the archive. > > We are running postgres 7.4.1 The old fashioned way of doing this was to dump the database, change the appropriate fields in the dump, and reload. It's certainly faster than the rename add drop column boogie, and cleans up your data store at the same time. Back in the days of transaction wrap around and index bloat, it wasn't such a bad thing to do every few months anyway. :-) Speaking of which, I just checked, and it appears I've got growing system index on stats problems in my older 7.2 database, so I'm off dump and reload it...