Re: Changing column names in tables 2 - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Changing column names in tables 2
Date
Msg-id 20080305200112.GX4755@alvh.no-ip.org
Whole thread Raw
In response to Changing column names in tables 2  ("Tony Cade" <arcade646@googlemail.com>)
Responses Re: Changing column names in tables 2  (dmp <danap@ttc-cmc.net>)
List pgsql-general
Tony Cade wrote:

> There are too many fields to issue alter table commands to rename in SQL so
> my question is , is it safe to use a query such as
>
>     select relfilenode from pg_class where relname='rates'

> update  pg_attribute set attname=lower(attname) where attnum >0 and
> attrelid=nnnn ( from above query)

Don't do that.  It's far better to create a shell script, or PL/pgSQL
function, whatever suits you, to get the table/column names from the
catalog and then produce the ALTER TABLE commands you need.

Playing directly with the catalogs is *never* supposed.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

pgsql-general by date:

Previous
From: "Tony Cade"
Date:
Subject: Changing column names in tables
Next
From: Tom Lane
Date:
Subject: Re: Requiring a password