Re: Listing table definitions by only one command - Mailing list pgsql-sql

From Giuseppe Broccolo
Subject Re: Listing table definitions by only one command
Date
Msg-id 51E81A53.7040200@2ndquadrant.it
Whole thread Raw
In response to Listing table definitions by only one command  (Carla Goncalves <cgourofino@hotmail.com>)
List pgsql-sql
<div class="moz-cite-prefix">Hi Carla,<br /><br /> Il 17/07/2013 17:29, Carla Goncalves ha scritto:<br
/></div><blockquotecite="mid:SNT139-W9B6944EFDF47E2E64EC54C2610@phx.gbl" type="cite"><style><!--
 
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style><div dir="ltr">Hi<br /> I would like to list the definition of all user tables by only one command. Is there
away to *not* show pg_catalog tables when using "\d ." in PostgreSQL 9.1.9?<br /></div></blockquote><br /> The simpler
waysimilar to a "\d ." I know is a query like this (supposing you are not interested also to 'information_schema'
schemeas well as 'pg_catalog', and interested only on tables list):<br /><br /> SELECT b.table_schema, a.table_name,
a.column_name,a.data_type, a.is_nullable FROM information_schema.columns a INNER JOIN <br /> (SELECT * FROM
information_schema.tablesWHERE table_type = 'BASE TABLE' AND table_schema <> 'pg_catalog' AND table_schema
<>'information_schema'  ORDER BY table_name) b <br /> ON a.table_name = b.table_name;<br /><br /> This query
outputis a table with the same fields shown with "\dS ." command, ordered by tables name and organized as follows:<br
/><br/>     table_schema | table_name | column_name | data_type | is_nullable <br />   
--------------------+----------------+-------------------+-------------+--------------<br/>      your_schema | 
your_table |    column_1     |   integer   |     YES<br />              ...           |         ...         |         
...           |       ...       |      ... <br /><br /> It's quite less readable than "\d." (you'll obtain just one
tablein output than a single table for each table name), but it is ordered by table name and could be useful.<br /><br
/>Hope it helps.<br /><br /> Giuseppe.<br />     <br /><br /><br /><pre class="moz-signature" cols="72">-- 
 
Giuseppe Broccolo - 2ndQuadrant Italy
PostgreSQL Training, Services and Support
<a class="moz-txt-link-abbreviated" href="mailto:giuseppe.broccolo@2ndQuadrant.it">giuseppe.broccolo@2ndQuadrant.it</a>
|<a class="moz-txt-link-abbreviated" href="http://www.2ndQuadrant.it">www.2ndQuadrant.it</a></pre> 

pgsql-sql by date:

Previous
From: Wes James
Date:
Subject: Re: Listing table definitions by only one command
Next
From: Mag Gam
Date:
Subject: Mag Gam