RE: sequences and tables

From: Michael Davis <mdavis(at)sevainc(dot)com>
To: "'Nelio Alves Pereira Filho'" <nelio(at)ifx(dot)com(dot)br>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: RE: sequences and tables
Date: 2001-01-03 16:47:02
Message-ID: 01C0756A.21B61C60.mdavis@sevainc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Try:

--This shows all default values for columns
SELECT DISTINCT c.relname, a.attname, t.typname, pa.adsrc, a.atttypid
FROM pg_attribute a, pg_class c, pg_type t, pg_attrdef pa
WHERE a.attrelid = c.oid
AND a.atttypid = t.oid
AND c.oid = pa.adrelid
AND a.attnum = pa.adnum
AND upper(c.relname) = 'TABLE_NAME';

--This shows all columns that reference a sequence
SELECT DISTINCT c.relname, a.attname, t.typname, pa.adsrc, a.atttypid
FROM pg_attribute a, pg_class c, pg_type t, pg_attrdef pa
WHERE a.attrelid = c.oid
AND a.atttypid = t.oid
AND c.oid = pa.adrelid
AND a.attnum = pa.adnum
AND upper(pa.adsrc) like '%SEQUENCE_NAME%';

-----Original Message-----
From: Nelio Alves Pereira Filho [SMTP:nelio(at)ifx(dot)com(dot)br]
Sent: Wednesday, January 03, 2001 7:13 AM
To: pgsql-general(at)postgresql(dot)org
Subject: sequences and tables

Where do I find information about a sequence? I'd like to know what are
the table and column referenced by a sequence. As its name may be
truncated, it's not a consistent place to look for.

The system tables didn't seem to help.

Thanks

--
Nelio Alves Pereira Filho
IFX Networks - www.ifx.com.br
+55 11 3365-5863
nelio(at)ifx(dot)com(dot)br

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-01-03 16:52:13 Re: Pb importing data in v. 7.0.3
Previous Message Tim Uckun 2001-01-03 16:44:40 Re: Re: RE: Re: MySQL and PostgreSQL speed compare