pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stefan Holzheu <stefan.holzheu@bitoek.uni-bayreuth.de>
To: ADMIN <pgsql-admin@postgresql.org>
Subject: varchar to text
Date: Tue, 13 Apr 2004 11:49:46 +0200
Message-ID: <407BB7BA.9070103@bitoek.uni-bayreuth.de> (raw)

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

Regards
	
	Stefan





-- 
-----------------------------
Dr. Stefan Holzheu
Tel.: 0921/55-5720
Fax.: 0921/55-5799
BITOeK Wiss. Sekretariat
Universitaet Bayreuth
D-95440 Bayreuth
-----------------------------



view thread (2+ messages)  latest in thread

Message-ID: <407BB7BA.9070103@bitoek.uni-bayreuth.de>
Permalink:  ../407BB7BA.9070103@bitoek.uni-bayreuth.de/
Also on:    postgresql.org/message-id/407BB7BA.9070103@bitoek.uni-bayreuth.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: stefan.holzheu@bitoek.uni-bayreuth.de
  Subject: Re: varchar to text
  In-Reply-To: <407BB7BA.9070103@bitoek.uni-bayreuth.de>
  References: <407BB7BA.9070103@bitoek.uni-bayreuth.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox