Thread

  1. RE: sequences and tables

    Michael J Davis <mdavis@sevainc.com> — 2001-01-03T16:47:02Z

    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@ifx.com.br]
    Sent:	Wednesday, January 03, 2001 7:13 AM
    To:	pgsql-general@postgresql.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@ifx.com.br