Re: Returning the name of a primary key - Mailing list pgsql-hackers

From Jim C. Nasby
Subject Re: Returning the name of a primary key
Date
Msg-id 20050517052425.GK30902@decibel.org
Whole thread Raw
In response to Re: Returning the name of a primary key  (Alvaro Herrera <alvherre@surnet.cl>)
List pgsql-hackers
On Mon, May 16, 2005 at 02:35:03PM -0400, Alvaro Herrera wrote:
> On Mon, May 16, 2005 at 01:25:46PM -0500, Juan Pablo Espino wrote:
> 
> > I need to write a function that retrieve the name of at least one
> > table primary key, if it exists.  The only argument passed to the
> > function is the table name.  I have thought something like this:
> 
> Why mess around with a C function, if you can do it in straight SQL?
> You can write a SQL function if need be.

http://lnk.nu/cvs.pgfoundry.org/2op.sql is an example of how to get the
info in pure SQL.
-- 
Jim C. Nasby, Database Consultant               decibel@decibel.org 
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: SQL99 hierarchical queries stalled
Next
From: Tom Lane
Date:
Subject: Learning curves and such (was Re: pgFoundry)