Thread: Perl Interface

Perl Interface

From
Robert Hiltibidal
Date:
Morning,

I use the Pg.pm module to access a postgres database (postgres 6.5.1)

How can I get perl to pull the field names from a table? 

For example, lets say I have diffrerent tables. I want one script to pull
the field names, not necessarily the values, from those 5 tables. Any ideas?

Thanks,

-Rob 



Re: [INTERFACES] Perl Interface

From
Tom Lane
Date:
Robert Hiltibidal <rob@y2k.state.il.us> writes:
> How can I get perl to pull the field names from a table? 

This isn't specifically a perl question, it's just a matter of knowing
which system tables to look in.  Try

select attname from pg_attribute, pg_class where
attrelid = pg_class.oid and attnum > 0 and relname = 'XXX';

BTW, it's easy to explore the system tables in psql.  Use \dS to get
a list of system tables, and then \d and normal SQL commands to look
at any of them that sound interesting.  Or look at the definitions in
pgsql/src/include/catalog/.
        regards, tom lane