pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dado Feigenblatt <dado@wildbrain.com>
Cc: Magnus Landahl <magnus.landahl@datessa.se>
Cc: pgsql <pgsql-sql@postgresql.org>
Subject: Re: Get the tables names?
Date: Fri, 20 Jul 2001 17:02:00 -0400
Message-ID: <5021.995662920@sss.pgh.pa.us> (raw)
In-Reply-To: <3B588D48.80803@wildbrain.com>
References: <9j67ra$m1$1@news.tht.net>
	<3B588D48.80803@wildbrain.com>

Dado Feigenblatt <dado@wildbrain.com> writes:
> 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?

It certainly is not.  Even if it was, the above would exclude ordinary
tables that had been created by the dbadmin/superuser.

The convention that's really used is that system tables have names
starting with 'pg_' --- the code will actually not let you create a
table with such a name, so that the convention can be relied on.
So the correct way to exclude system tables is

SELECT * FROM pg_class WHERE relkind = 'r' and relname not like 'pg_%';

If you try "\d" in psql after starting it with -E option, you will
discover that this is indeed what psql does ...

			regards, tom lane



view thread (10+ messages)  latest in thread

Message-ID: <5021.995662920@sss.pgh.pa.us>
Permalink:  ../5021.995662920@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5021.995662920@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dado@wildbrain.com, magnus.landahl@datessa.se
  Subject: Re: Get the tables names?
  In-Reply-To: <5021.995662920@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox