Thread

  1. query column def

    Peter Harvey <pharvey@codebydesign.com> — 2001-08-21T18:49:54Z

    Hi;
    
    I am reverse engineering a PostgreSQL database by querying catalog
    tables. I have run into a problem where I can not determine the exact
    info used in i.e. the CREATE TABLE statement. For example; how to
    determine the exact precision/length and scale used in a NUMERIC(p,s)
    column def.
    
    Looking at the PostgreSQL ODBC driver I see that it does some funky
    stuff such as reporting VARCHAR(maxlen) instead of i.e. VARCHAR(50) or
    whatever the column def was. So it appears that the author had similar
    problems. The result is that the ODBC driver does not appear to be
    absolutely accurate.
    
    Is this information availible somewhere in the catalog tables?
    
    Peter
    
    
    
    
    
  2. Re: query column def

    Tom Lane <tgl@sss.pgh.pa.us> — 2001-08-21T19:22:59Z

    Peter Harvey <pharvey@codebydesign.com> writes:
    > Is this information availible somewhere in the catalog tables?
    
    Yes, in the atttypmod column of pg_attribute.
    
    I'd recommend looking at psql's \d commands (describe.c), or at
    pg_dump, to see the approved way to retrieve catalog info.  Those
    are kept up to date pretty faithfully, whereas other interfaces
    aren't necessarily.  (Feel free to submit a patch to fix ODBC...)
    
    			regards, tom lane