Re: Question Again
От | Andrew McMillan |
---|---|
Тема | Re: Question Again |
Дата | |
Msg-id | 39B6A407.AA2B215D@catalyst.net.nz обсуждение исходный текст |
Ответ на | Question Again ("Cristian D. GAL" <gal@mail.com>) |
Список | 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@cat-it.co.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
В списке pgsql-general по дате отправления: