Re: Get the tables names?

From: "dado feigenblatt" <dado(at)wildbrain(dot)com>
To: <jburton(at)scw(dot)org>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Get the tables names?
Date: 2001-07-23 17:10:42
Message-ID: 007901c1139a$7ac337b0$b3f22ccf@dadowin
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


----- Original Message -----
From: "Joel Burton" <jburton(at)scw(dot)org>
To: "Dado Feigenblatt" <dado(at)wildbrain(dot)com>
Cc: "Magnus Landahl" <magnus(dot)landahl(at)datessa(dot)se>; "pgsql"
<pgsql-sql(at)postgresql(dot)org>
Sent: Friday, July 20, 2001 1:43 PM
Subject: Re: Get the tables names?

> On Fri, 20 Jul 2001, Dado Feigenblatt wrote:
>
> > Magnus Landahl wrote:
> >
> > >Hi everybody!
> > >
> > >Is it possible to get the names of all tables in the database with a
sql
> > >query??
> > >
> > >Best regards,
> > >
> > >Magnus
> > >
> > >
> > >
> > >---------------------------(end of
broadcast)---------------------------
> > >TIP 3: if posting/reading through Usenet, please send an appropriate
> > >subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> > >message can get through to the mailing list cleanly
> > >
> > >
> > >
> > Not sure if this is the best way, but it works.
> > SELECT relname , relowner from pg_class where relkind = 'r';
> >
> > The only thing is that this includes system tables.
> > So if you want to strip those you need to
> > SELECT relname , relowner FROM pg_class WHERE relkind = 'r' and
> > relowner != 26;
> >
> > Is user postgres always 26? Maybe you have to find that out first.
>
> system tables all ~ '^pg', which is probably a better check than
> user=postgresql.
>
>
> hth,
> --
> Joel Burton <jburton(at)scw(dot)org>
> Director of Information Systems, Support Center of Washington

You never know when someone will name their tables starting with "pg".
Well, you never know when someone will create their tables as user postgres
either.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-07-23 17:49:52 Re: unique index on more than one field using functions
Previous Message Giles Lean 2001-07-23 17:03:34 Re: Full-text Indexing and Primary Keys