Thread: metadata and views

metadata and views

From
Rip
Date:
Hi all,
    I trying to extract the metadata from a view and getting spotty results.
Using the following:

SELECT a.attnum, a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull,
a.atthasdef FROM pg_class as c, pg_attribute a, pg_type t WHERE a.attnum >
0 and a.attrelid = c.oid and c.relname = 'users' and a.atttypid = t.oid
order by a.attnum

I get correct results on a table for a.attnum, a.attname, t.typname,
a.attlen, a.atttypmod, a.attnotnull and a.atthasdef, but for a view
a.attnotnull and a.atthasdef  return nothing.

Any clues anyone?



Re: metadata and views

From
Tom Lane
Date:
Rip <rip@onlineinfo.net> writes:
> I get correct results on a table for a.attnum, a.attname, t.typname,
> a.attlen, a.atttypmod, a.attnotnull and a.atthasdef, but for a view
> a.attnotnull and a.atthasdef  return nothing.

What were you expecting?  A view doesn't have constraints, nor default
values for columns.

            regards, tom lane