Re: Question Again

From: Andrew McMillan <Andrew(at)catalyst(dot)net(dot)nz>
To: "Cristian D(dot) GAL" <gal(at)mail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Question Again
Date: 2000-09-06 20:07:35
Message-ID: 39B6A407.AA2B215D@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Cristian D. GAL" wrote:
>
> >> is there a solution to find infos about a table?
> >> eg: I want to know what field names and their types has a certain table
> >> from a db.
>
> I read TFM and found -c option to 'psql' and came up with this trick:
>
> #!/some/where/perl
> use CGI qw(:standard);
>
> my $table = param('table');
> my $fields = `psql $DBNAME -h $DBHOST -U $DBUSER -c \"\\d $table\" -q`;
> print $fields;
> ..
>
> is there something a little more elegant than this?

strings /usr/lib/postgresql/bin/psql

Will give you a useful reference to the actual database queries behind
that \d, or you could look at the source, of course!

psql may not be in that location if you don't use Debian, of course :-)

Cheers,
Andrew.
--
_____________________________________________________________________
Andrew McMillan, e-mail: Andrew(at)cat-it(dot)co(dot)nz
Catalyst IT Ltd, PO Box 10-225, Level 22, 105 The Terrace, Wellington
Me: +64 (21) 635 694, Fax: +64 (4) 499 5596, Office: +64 (4) 499 2267

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martin A. Marques 2000-09-06 20:47:53 postgresql-7.0.2 rpms
Previous Message jeff seaman 2000-09-06 20:04:19 postgres and windows NT