A bozo's blog
SELECT attname, format_type(atttypid, atttypmod) AS type FROM pg_attribute WHERE attrelid = 'foo'::regclass AND attnum > 0 AND NOT attisdropped ORDER BY attnum;