From: msi77 <msi77@yandex.ru>
To: shuaixf <shuaixf@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Re: how can I get the length of columns of a table by system tables/views
Date: Sat, 10 Sep 2011 09:51:28 +0400
Message-ID: <531401315633888@web20.yandex.ru> (raw)
In-Reply-To: <1315572818036-4786248.post@n5.nabble.com>
References: <1315451354762-4780987.post@n5.nabble.com>
<1315572818036-4786248.post@n5.nabble.com>
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@gmail.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-tab...
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: msi77@yandex.ru, shuaixf@gmail.com
Subject: Re: Re: how can I get the length of columns of a table by system tables/views
In-Reply-To: <531401315633888@web20.yandex.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox