Re: Re: how can I get the length of columns of a table by system tables/views

From: msi77 <msi77(at)yandex(dot)ru>
To: shuaixf <shuaixf(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Re: how can I get the length of columns of a table by system tables/views
Date: 2011-09-10 05:51:28
Message-ID: 531401315633888@web20.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Why not to use information schema:

select column_name, character_maximum_length from information_schema.columns where table_name ='table name'

09.09.2011, 16:53, "shuaixf" <shuaixf(at)gmail(dot)com>:
> SELECT a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod)
> FROM pg_catalog.pg_attribute a
> WHERE a.attrelid = (SELECT pg_class.oid
>                     FROM pg_class INNER JOIN pg_namespace
>                        ON (pg_class.relnamespace = pg_namespace.oid
>                            AND lower(pg_namespace.nspname) = 'public')
>                    WHERE pg_class.relname='tablename')
>   AND a.attnum > 0 AND NOT a.attisdropped
> ORDER BY a.attnum;
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/how-can-I-get-the-length-of-columns-of-a-table-by-system-tables-views-tp4780987p4786248.html
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Gabriel Filipiak 2011-09-10 06:45:32 Dynamic sql
Previous Message Waqar Azeem 2011-09-09 13:31:02 Re: My Trigger is not working :(