Re: The need to know if a field is using/connected to a sequence - Mailing list pgsql-sql

From A.Bhuvaneswaran
Subject Re: The need to know if a field is using/connected to a sequence
Date
Msg-id Pine.LNX.4.44.0304101341560.1046-100000@Bhuvan.bksys.co.in
Whole thread Raw
In response to The need to know if a field is using/connected to a sequence  ("Ries van Twisk" <ries@jongert.nl>)
Responses Re: The need to know if a field is using/connected to a sequence  ("Ries van Twisk" <ries@jongert.nl>)
List pgsql-sql
> I currently use this to get field information of a table:
> Now I just want to know (boolean field maby??) if a field is using/connected
> to q sequence or not.
> Which table should I access to get this information

How can a boolean field use/connect q sequence? I got that you want to
know the fields which use sequence for their default value. If i am right,
here is the solution. The default value details are in pg_attrdef table.

SELECT 
a.attnum, 
c.relname, 
a.attname, 
d.adsrc as default 
from 
pg_attribute a, 
pg_class c, 
pg_attrdef d 
where 
a.attrelid = c.oid 
and a.attnum = d.adnum 
and d.adrelid = c.oid 
and a.attnum > 0 
and c.relname = 'your_table_name' 
and d.adsrc ~* 'your_sequence_name'
order by a.attnum;

Hope it helps.

regards,
bhuvaneswaran



pgsql-sql by date:

Previous
From: "Ries van Twisk"
Date:
Subject: The need to know if a field is using/connected to a sequence
Next
From: Olleg Samojlov
Date:
Subject: Re: auto-commit