Search Postgresql Archives

Re: Changing column names in tables 2

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

 



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 lowercase for the table(s) and field(s).
If psql is to much of a hassle, Just use MyJSQLView to dump
the database and removed the quotes, ". You should of been able
to remove the quotes directly in MyJSQLView during the dump,
but I just tried it and it is broken. Edit | Preference | Data Export |
SQL, set empty string identifier. I always recommend backing up
data to get back where you started just in case things get screwed up,
so pg_dump everything before starting.

danap.

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.


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

              http://archives.postgresql.org/

[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