Re: The need to know if a field is using/connected to a sequence

From: "A(dot)Bhuvaneswaran" <bhuvansql(at)myrealbox(dot)com>
To: Ries van Twisk <ries(at)jongert(dot)nl>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: The need to know if a field is using/connected to a sequence
Date: 2003-04-10 08:25:37
Message-ID: Pine.LNX.4.44.0304101341560.1046-100000@Bhuvan.bksys.co.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Olleg Samojlov 2003-04-10 09:12:27 Re: auto-commit
Previous Message Ries van Twisk 2003-04-10 06:36:02 The need to know if a field is using/connected to a sequence