Re: Querying database for table pk - better way?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Querying database for table pk - better way?
Дата
Msg-id b42b73150709051608s49080187s96e4816a1c56ecf1@mail.gmail.com
обсуждение исходный текст
Ответ на Querying database for table pk - better way?  (Josh Trutwin <josh@trutwins.homeip.net>)
Ответы Re: Querying database for table pk - better way?  (Josh Trutwin <josh@trutwins.homeip.net>)
Список pgsql-general
On 9/5/07, Josh Trutwin <josh@trutwins.homeip.net> wrote:
> I have a php application that needs to query the PK of a table - I'm
> currently using this from the information_schema views:

try this:
CREATE OR REPLACE VIEW PKEYS AS
    SELECT nspname as schema, c2.oid as tableoid, c2.relname as table,
      substring(pg_catalog.pg_get_indexdef(i.indexrelid, 0, true) from
E'\\((.*)\\)')
    FROM pg_catalog.pg_class c, pg_catalog.pg_class c2,
pg_catalog.pg_index i, pg_namespace n
    WHERE c.oid = i.indrelid AND i.indexrelid = c2.oid AND c.relkind = 'r'
      AND i.indisprimary AND c.relnamespace = n.oid
    ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname;

merlin

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

Предыдущее
От: Liam Slusser
Дата:
Сообщение: pg_dump doesn¹t dump everything?
Следующее
От: "A.M."
Дата:
Сообщение: Re: pg_dump doesn't dump everything?