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

From: shuaixf <shuaixf(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: how can I get the length of columns of a table by system tables/views
Date: 2011-09-10 05:45:26
Message-ID: 1315633526507-4788780.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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-tp4778911p4788780.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Karuna Karpe 2011-09-10 11:23:14 oracle to postgres migration
Previous Message Tom Lane 2011-09-09 13:57:10 Re: how can I get the length of columns of a table by system tables/views