Thread: How to list schemas and table in psql?

How to list schemas and table in psql?

From
"Phillip J. Allen"
Date:
Hi all,

I just got the PG 7.3.1 installed and am now experimenting with
schemas.  Now when I do a "\dt" in psql I only get a listing of tables
in the current schema (public by default).

So how do I get a listing in psql for:

1. all the schemas that exist in the database
2. all the tables in all schemas

I just came over to postgresql about 1 1/2 years ago from MS ACCESS and
now I am quite interested in schemas.  I am trying to determine if I
want to put all my different databases into one big database under
different schemas (it makes sense considering my various databases often
use the same look-up/code table and keeping them all sincronized is a
bit of a pain).  But before I go re-arranging all of my last years work
I think it would be wise to evaluate all the ins-and-outs first.  No
reason to make more problems for myself.

Thanks,

Phillip J. Allen
Consulting Geochemist/Geologist
Lima Peru
e-mail: paallen@attglobal.net


Re: How to list schemas and table in psql?

From
Ron Johnson
Date:
On Thu, 2003-01-09 at 18:50, Phillip J. Allen wrote:
> Hi all,
>
> I just got the PG 7.3.1 installed and am now experimenting with
> schemas.  Now when I do a "\dt" in psql I only get a listing of tables
> in the current schema (public by default).
>
> So how do I get a listing in psql for:
>
> 1. all the schemas that exist in the database
> 2. all the tables in all schemas
>
> I just came over to postgresql about 1 1/2 years ago from MS ACCESS and
> now I am quite interested in schemas.  I am trying to determine if I
> want to put all my different databases into one big database under
> different schemas (it makes sense considering my various databases often
> use the same look-up/code table and keeping them all sincronized is a
> bit of a pain).  But before I go re-arranging all of my last years work
> I think it would be wise to evaluate all the ins-and-outs first.  No
> reason to make more problems for myself.

Are all of your databases on the same box anyway, with no prospect of
any outgrowing the box?

One way to keep them synchronized w/o schemas is to have a script that
applies the same SQL to all databases.  It's trivial in Perl & Python.
Should also be in bash...

--
+------------------------------------------------------------+
| Ron Johnson, Jr.     mailto:ron.l.johnson@cox.net          |
| Jefferson, LA  USA   http://members.cox.net/ron.l.johnson  |
|                                                            |
| "Basically, I got on the plane with a bomb. Basically, I   |
|  tried to ignite it. Basically, yeah, I intended to damage |
|  the plane."                                               |
|    RICHARD REID, who tried to blow up American Airlines    |
|                  Flight 63                                 |
+------------------------------------------------------------+


Re: How to list schemas and table in psql?

From
Tom Lane
Date:
"Phillip J. Allen" <paallen@attglobal.net> writes:
> I just got the PG 7.3.1 installed and am now experimenting with
> schemas.  Now when I do a "\dt" in psql I only get a listing of tables
> in the current schema (public by default).

> So how do I get a listing in psql for:

> 1. all the schemas that exist in the database

As of 7.3, we didn't get around to providing a backslash command in psql
to do this, but "select * from pg_namespace" will answer.

> 2. all the tables in all schemas

Try "\dt *.*"

            regards, tom lane