From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Igor Korot <ikorot01(at)gmail(dot)com> |
Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Getting the table ID |
Date: | 2022-07-19 03:21:13 |
Message-ID: | CAKFQuwbJJJOx5M0Z6Xr4gVSSeCG6ayrxhJFi=Spf1q0KW5d3qA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Jul 18, 2022 at 8:11 PM Igor Korot <ikorot01(at)gmail(dot)com> 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Christophe Pettus | 2022-07-19 03:24:00 | Re: equivalent thing of mtr in mysql |
Previous Message | Igor Korot | 2022-07-19 03:10:14 | Getting the table ID |