Skip site navigation (1) Skip section navigation (2)

varchar to text

From: Stefan Holzheu <stefan(dot)holzheu(at)bitoek(dot)uni-bayreuth(dot)de>
To: ADMIN <pgsql-admin(at)postgresql(dot)org>
Subject: varchar to text
Date: 2004-04-13 09:49:46
Message-ID: 407BB7BA.9070103@bitoek.uni-bayreuth.de (view raw or flat)
Thread:
Lists: pgsql-admin
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
-----------------------------

Responses

pgsql-admin by date

Next:From: Nichlas LöfdahlDate: 2004-04-13 15:26:01
Subject: log_min_cost_statement
Previous:From: JinNet PickerDate: 2004-04-13 08:36:59
Subject: Postgres Admin - Export Database

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group