Re: Changing column names in tables 2

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Changing column names in tables 2
Дата
Msg-id 20080305200112.GX4755@alvh.no-ip.org
обсуждение исходный текст
Ответ на Changing column names in tables 2  ("Tony Cade" <arcade646@googlemail.com>)
Ответы Re: Changing column names in tables 2  (dmp <danap@ttc-cmc.net>)
Список 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 по дате отправления:

Предыдущее
От: "Tony Cade"
Дата:
Сообщение: Changing column names in tables
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Requiring a password