Thread: pg_ ?

pg_ ?

From
Popeanga Marian
Date:
Hello all,

          Witch is the system view from where i can get columns for all 
tables and views ?
Just like when pgsql> \d view

-- 
Popeanga Marian
DBA Oracle
CNLO Romania



Re: pg_ ?

From
Achilleus Mantzios
Date:
On Tue, 6 May 2003, Popeanga Marian wrote:

> Hello all,
> 
> 
>            Witch is the system view from where i can get columns for all 
> tables and views ?
> Just like when pgsql> \d view

refine (get rid of cmax/cmin.....) something like:

SELECT relname,attname from pg_attribute,pg_class where attrelid = 
pg_class.oid order by relname,attname;

> 
> 

-- 
==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-210-8981112
fax:    +30-210-8981877
email:  achill@matrix.gatewaynet.com       mantzios@softlab.ece.ntua.gr



Re: pg_ ?

From
Rajesh Kumar Mallah
Date:

pg_attribute.

in general if you start psql with -E option
psql will print the various queries which it
uses on system catalogs for displaying 
various kind of information.


Regds
mallah.

On Tuesday 06 May 2003 5:32 pm, Popeanga Marian wrote:
> Hello all,
>
>
>            Witch is the system view from where i can get columns for all
> tables and views ?
> Just like when pgsql> \d view

-- 
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)

Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.



Re: pg_ ?

From
"A.Bhuvaneswaran"
Date:
>            Witch is the system view from where i can get columns for all 
> tables and views ?
> Just like when pgsql> \d view

pg_class is the *system table* from which you can get the columns of all 
tables and views.

regards,
bhuvaneswaran



Re: pg_ ?

From
"A.Bhuvaneswaran"
Date:
> >            Witch is the system view from where i can get columns for all 
> > tables and views ?
> > Just like when pgsql> \d view
> 
> pg_class is the *system table* from which you can get the columns of all
             ^^^^^^^!
 
> tables and views.

Sorry. It is details, not columns. To get columns we can use pg_attribute
system table. For example the below sql would get the column names,

select c.relname, a.attname from pg_class c, pg_attribute a, pg_namespace
n where c.oid = a.attrelid and a.attnum > 0 and c.relnamespace = n.oid and
n.nspname = 'my_schema' and c.relname = 'my_table';

=> \d pg_attribute -- for more details

regards,
bhuvaneswaran



Re: pg_ ?

From
Achilleus Mantzios
Date:
On Tue, 6 May 2003, A.Bhuvaneswaran wrote:

> >            Witch is the system view from where i can get columns for all 
> > tables and views ?
> > Just like when pgsql> \d view
> 
> pg_class is the *system table* from which you can get the columns of all 
> tables and views.

Well just try:

SELECT relname,attname||' : '||typname from pg_attribute,pg_class,pg_type 
where attrelid = pg_class.oid and attnum > 1 and atttypid = pg_type.oid 
order by relname,attname;

> 
> regards,
> bhuvaneswaran
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> 

-- 
==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-210-8981112
fax:    +30-210-8981877
email:  achill@matrix.gatewaynet.com       mantzios@softlab.ece.ntua.gr



Re: pg_ ?

From
Popeanga Marian
Date:
<br /><br /> Rajesh Kumar Mallah wrote:<br /><blockquote cite="mid200305061829.36866.mallah@trade-india.com"
type="cite"><prewrap="">
 
pg_attribute.

in general if you start psql with -E option
psql will print the various queries which it
uses on system catalogs for displaying 
various kind of information. </pre></blockquote> Thanks guys,  This -E option i didn'tknow about it!<br /><blockquote
cite="mid200305061829.36866.mallah@trade-india.com"type="cite"><pre wrap="">
 

Regds
mallah.

On Tuesday 06 May 2003 5:32 pm, Popeanga Marian wrote: </pre><blockquote type="cite"><pre wrap="">Hello all,

          Witch is the system view from where i can get columns for all
tables and views ?
Just like when pgsql> \d view   </pre></blockquote><pre wrap=""> </pre></blockquote><br /><pre class="moz-signature"
cols="$mailwrapcol">--
 
Popeanga Marian
DBA Oracle
CNLO Romania
</pre><br />