2006.09.09 Saturday | 22:03

  カラム一覧(含む型) ふるいむかし

↓とりあえず、WEB で見つけたもの
select att.attname, att.typname, att.attlen,
att.attnotnull, d.description, att.objsubid
from (select a.attname, t.typname, a.attlen,
a.attnotnull, a.attrelid as objoid, a.attnum as objsubid
from pg_attribute a, pg_class c, pg_type t
where c.oid = a.attrelid
and t.oid = a.atttypid
and c.relname = '得意先マスタ'
and a.attnum > 0) att
left outer join pg_description d using(objoid, objsubid)
order by att.objsubid 


↓作ってみたもの
select

pg_attribute.attname
,replace(pg_type.typname,'_','') as typename
,pg_attribute.atttypmod-4 as charlen
,pg_attribute.atttypid
,pg_attribute.attnum

from 
pg_class
inner join pg_attribute
on pg_class.relfilenode = pg_attribute.attrelid
inner join pg_type
on pg_attribute.atttypid = pg_type.typelem

where pg_class.relname = '商品マスタ'
and pg_attribute.attnum > 0

order by pg_attribute.attnum