Re: how to save primary key constraints - Mailing list pgsql-general

From J.V.
Subject Re: how to save primary key constraints
Date
Msg-id 4E94D042.4050804@gmail.com
Whole thread Raw
In response to Re: how to save primary key constraints  (John R Pierce <pierce@hogranch.com>)
Responses Re: how to save primary key constraints  (Raymond O'Donnell <rod@iol.ie>)
Re: how to save primary key constraints  (John R Pierce <pierce@hogranch.com>)
List pgsql-general
pg_catalog table does not exist.

This is a solution for PostgreSQL 8.4.

If you know of a way I can get all primary key fields or have a query
that will work in 8.4, please help.  I have done a lot of research and
cannot find a simple way.


J.V.

On 10/11/2011 3:29 PM, John R Pierce wrote:
> On 10/11/11 2:16 PM, J.V. wrote:
>> I need to be able to query for all primary keys and save the table
>> name and the name of the primary key field into some structure that I
>> can iterate through later.
>>
>> How would I go about this?  I want to hard code the number of tables
>> and be able to iterate through some structure to get the table name
>> and the primary key field.
>
> that info is all in pg_catalog... pg_tables is a view of all tables...
> if you left join that with pg_index qualified by indisprimary, you'll
> probably get what you need.  you'll probably need to join pg_namespace
> to get the index name from its oid.
>
>
>

pgsql-general by date:

Previous
From: Joe Abbate
Date:
Subject: Re: how to find primary key field name?
Next
From: Raymond O'Donnell
Date:
Subject: Re: how to save primary key constraints