Re: OID Usage

From: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, Bo Lorentsen <bl(at)netgroup(dot)dk>, "pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: OID Usage
Date: 2005-01-15 00:39:25
Message-ID: 20050115003925.GJ67721@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 14, 2005 at 05:10:10PM -0300, Alvaro Herrera wrote:
> On Fri, Jan 14, 2005 at 12:20:50PM -0700, Michael Fuhr wrote:
> > On Fri, Jan 14, 2005 at 07:44:18PM +0100, Bo Lorentsen wrote:
> > > Alvaro Herrera wrote:
> > >
> > > >You can create a function to get the sequence name attached to a table.
> > > >Of course, you should take into account the fact that there could be
> > > >more than one (two serial fields in a table are rare but not
> > > >impossible), but if your tables have only one sequence you should be OK.
> > > >
> > > Are there a way to find and test if it is a primary key ?
> >
> > pg_index has an indisprimary column.
>
> Yeah, though things get hairy that way because you have to peek at
> pg_attribute to match the objsubid in pg_depend; and self-join pg_class
> to get to the index itself. Not sure if it all can be done in a single
> query.

If you do manage to write a function that will do this I hope you can
share it with the community. IMHO PostgreSQL could do with more
functions for querying the system catalogs.
--
Jim C. Nasby, Database Consultant decibel(at)decibel(dot)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?"

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Kammer 2005-01-15 00:48:12 serial increments on failed insert
Previous Message PFC 2005-01-15 00:08:47 Re: MOVE