Re: Identification of serial fields

From: Carlos Guzman Alvarez <carlosga(at)telefonica(dot)net>
To: Developement <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Identification of serial fields
Date: 2003-08-03 10:22:34
Message-ID: 3F2CE26A.2090209@telefonica.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello:

Finally after some tests i'm doing this:

SELECT pg_namespace.nspname AS TABLE_SCHEMA,
pg_class.relname AS TABLE_NAME,
pg_attribute.attname AS COLUMN_NAME,
pg_attribute.atttypid AS DATA_TYPE,
pg_attribute.attlen AS COLUMN_SIZE,
pg_attribute.attndims AS COLUMN_DIMENSIONS,
pg_attribute.attnum AS ORDINAL_POSITION,
pg_attribute.atthasdef AS HAS_DEFAULT,
pg_attrdef.adsrc AS COLUMN_DEFAULT,
pg_attribute.attnotnull AS IS_NOT_NULL,
(pg_depend.objid is not null) AS IS_AUTOINCREMENT,
case pg_attribute.attstorage when 'p' THEN 'PLAIN' when 'e' THEN
'EXTERNAL' when 'm' THEN 'MAIN' when 'x' THEN 'EXTENDED' END AS STORAGE,
pg_description.description AS DESCRIPTION
FROM pg_attribute
left join pg_class ON pg_attribute.attrelid = pg_class.oid
left join pg_namespace ON pg_class.relnamespace = pg_namespace.oid
left join pg_attrdef ON (pg_class.oid = pg_attrdef.adrelid AND
pg_attribute.attnum = pg_attrdef.adnum)
left join pg_description ON (pg_attribute.attrelid =
pg_description.objoid AND pg_attribute.attnum = pg_description.objsubid)
left join pg_depend ON (pg_attribute.attrelid = pg_depend.refobjid AND
pg_attribute.attnum = pg_depend.refobjsubid AND pg_depend.deptype = 'i')
WHERE pg_attribute.attisdropped = false AND pg_attribute.attnum > 0
ORDER BY pg_namespace.nspname, pg_class.relname, pg_attribute.attnum

--
Best regards

Carlos Guzmán Álvarez
Vigo-Spain

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?= 2003-08-03 12:57:15 SQL2003 GENERATED ... AS ... syntax
Previous Message Bruce Momjian 2003-08-03 06:05:19 working on release