Re: [GENERAL] Changing column names in tables

2008-03-07 Thread Tony Cade
Why are there too many to fix with ALTER? > I mean that there are too many to fix with manually typed ALTER statements, pure laziness, so I am looking at an automated method. > Use SQL and the data dictionary to generate the DDL and pipe it into psql > (or spool it to disk and use that file as a

Re: [GENERAL] Changing column names in tables 2

2008-03-06 Thread Nis Jørgensen
Tony Cade skrev: > select relfilenode from pg_class where relname='rates' > > update pg_attribute set attname=lower(attname) where attnum >0 and > attrelid= ( from above query) Instead of the second one, do SELECT 'ALTER TABLE rates RENAME COLUMN ' || attname || ' TO ' || lower(attname

Re: [GENERAL] Changing column names in tables

2008-03-06 Thread Hoover, Jeffrey
Why are there too many to fix with ALTER? Use SQL and the data dictionary to generate the DDL and pipe it into psql (or spool it to disk and use that file as a sql script): psql your_db_name -t -c "select 'alter table '||t.tablename||' rename \"'||c.column_name||'\" to '||lower(c.column_name)||

Re: [GENERAL] Changing column names in tables 2

2008-03-05 Thread dmp
Hello Tony, Perhaps this will help maybe not. Since the original data import used quotes for the fields then any case was maintained in the creation of the new table(s) & fields(s). Just take your original import file and remove all the quotes, ",. Re-import and and PostgreSQL will use all lowerca

Re: [GENERAL] Changing column names in tables 2

2008-03-05 Thread Alvaro Herrera
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=