Search Postgresql Archives

Re: Getting the table ID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 18, 2022 at 8:11 PM Igor Korot <ikorot01@xxxxxxxxx> wrote:

There is a pg_namespace table - is this where the schema should come from?
If yes - how?
Looking at that table I don't see any unique fields...
Or is this something that is hidden?

Catalogs don't have all of the same metadata that user-space tables have.

"namespace" is the historical and internally used label for what we present to users as "schema"

In fact I'm trying to run following query:

SELECT c.oid FROM pg_class c, pg_namespace nc WHERE nc.oid =
c.relnamespace AND c.relname = ? AND nc.nspname = ?;

Then either relname or nspname caused the records to filter out because the join part of that where clause is correct.

I suggest you experiment using psql and literals so you can provide both actual queries and results more easily.  The whole self-contained script thing is very helpful.

You can also learn quite a bit by echoing queries in psql then using the various description metacommands that query these same catalogs - thus echoing the queries psql itself uses to answer this same question.

David J.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux