Re: Inspecting a DB - psql or system tables ?

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: Inspecting a DB - psql or system tables ?
Дата
Msg-id 4DDFECD9.8050304@fuzzy.cz
обсуждение исходный текст
Ответ на Inspecting a DB - psql or system tables ?  (Andre Majorel <aym-2lqsgp@teaser.fr>)
Ответы Re: Inspecting a DB - psql or system tables ?  (Andrew Sullivan <ajs@crankycanuck.ca>)
Список pgsql-general
Dne 27.5.2011 19:24, Andre Majorel napsal(a):
> Suppose you want to write a program that connects to a
> PostgreSQL database and lists its tables and views, the type of
> their columns and their relationships (REFERENCES) for automatic
> joins.
>
> Would you look at the system tables (pg_class et al.) or the
> output of psql \d, \dt, etc ?

System tables (old-fashioned pg_ catalogs or information_schema). Psql
reads those catalogs anyway, so parsing the output seems like an
unnecessary step.

> While parsing the output of psql is cumbersome, accessing the
> system tables seems more likely to break whenever a new version
> of PostgreSQL comes out.

Really? Those catalogs are pretty stable, and when changed they're
usually extended (new columns are added). So well written queries won't
break very often. Actually I'd expect the psql output to change much
more often.

regards
Tomas

В списке pgsql-general по дате отправления:

Предыдущее
От: fork
Дата:
Сообщение: Re: Inspecting a DB - psql or system tables ?
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: Inspecting a DB - psql or system tables ?