Re: column depends on sequence

From: Joshua Tolley <eggyknap(at)gmail(dot)com>
To: AI Rumman <rummandba(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: column depends on sequence
Date: 2010-08-05 13:18:55
Message-ID: 4c5aba42.21078e0a.57a8.0c3f@mx.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Aug 05, 2010 at 06:23:54PM +0600, AI Rumman wrote:
> I need to write a query to find the primary key column_names that depend
> on sequences.
> Any help please.

On the assumption that the sort of dependence you're looking for is one where
a column has a default value of nextval('some_sequence'), this worked for me:

select
attrelid::regclass || '.' || attname,
adsrc
from
pg_attrdef ad
join pg_attribute pa
on (ad.adrelid = pa.attrelid and pa.attnum = ad.adnum)
where
adsrc ~* 'nextval'

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marco Colombo 2010-08-05 13:28:56 Re: solaris slow
Previous Message AI Rumman 2010-08-05 12:23:54 column depends on sequence