Re: Changing column names in tables 2

From: Nis Jørgensen <nis(at)superlativ(dot)dk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Changing column names in tables 2
Date: 2008-03-06 22:25:00
Message-ID: fqpr07$7bs$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tony Cade skrev:

> select relfilenode from pg_class where relname='rates'
>
> update pg_attribute set attname=lower(attname) where attnum >0 and
> attrelid=nnnn ( from above query)

Instead of the second one, do

SELECT
'ALTER TABLE rates RENAME COLUMN ' || attname || ' TO ' ||
lower(attname) || ';'
FROM pg_attribute
WHERE attnum >0 AND attrelid=nnnn

Output to textfile, run through psql

Not tested,

Nis

In response to

Browse pgsql-general by date

  From Date Subject
Next Message newbiegalore 2008-03-07 00:28:42 Re: staring pgsql on fedora 8
Previous Message Tom Lane 2008-03-06 22:12:24 Re: staring pgsql on fedora 8