Search Postgresql Archives

Re: Changing column names in tables 2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux