Re: Getting Table Names in a Particular Database - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Getting Table Names in a Particular Database
Date
Msg-id CAOR=d=0oiCLRHny8QG1=xcsZJMNY+cSffMdOdh4Mg4ahSp45YA@mail.gmail.com
Whole thread Raw
In response to Re: Getting Table Names in a Particular Database  (Adarsh Sharma <adarsh.sharma@orkash.com>)
Responses Re: Getting Table Names in a Particular Database  (Scott Marlowe <scott.marlowe@gmail.com>)
List pgsql-general
On Tue, Aug 30, 2011 at 11:38 PM, Adarsh Sharma
<adarsh.sharma@orkash.com> wrote:
> Below is the output of the \d command
>
> SELECT n.nspname as "Schema",
>   c.relname as "Name",
>   CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i' THEN
> 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' END as "Type",
>   pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
> FROM pg_catalog.pg_class c
>      LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
> WHERE c.relkind IN ('r','v','S','')
>       AND n.nspname <> 'pg_catalog'
>       AND n.nspname <> 'information_schema'
>       AND n.nspname !~ '^pg_toast'
>   AND pg_catalog.pg_table_is_visible(c.oid)
> ORDER BY 1,2;
>
> I want to specify the database name & fetch tables from that but I think
> this query filters from schema 'public';

You HAVE to connect to the db you want to query about tables.  They
are isolated from each other.

pgsql-general by date:

Previous
From: Adarsh Sharma
Date:
Subject: Re: Getting Table Names in a Particular Database
Next
From: Scott Marlowe
Date:
Subject: Re: Getting Table Names in a Particular Database