Re: Get table OID

From: Melvin Davidson <melvin6925(at)gmail(dot)com>
To: Igor Korot <ikorot01(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Get table OID
Date: 2017-07-13 16:00:14
Message-ID: CANu8FixnW+_ph0MEdgCOUrAyzo68sKavU=zKfWX==PdJoFRyLQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 13, 2017 at 11:06 AM, Igor Korot <ikorot01(at)gmail(dot)com> wrote:

> Hi, Melvin,
>
> On Thu, Jul 13, 2017 at 10:42 AM, Melvin Davidson <melvin6925(at)gmail(dot)com>
> wrote:
>
>>
>> On Thu, Jul 13, 2017 at 10:36 AM, Igor Korot <ikorot01(at)gmail(dot)com> wrote:
>>
>>> Hi, ALL,
>>> Is it possible to get the table ID (or OID) from information_schema
>>> somewhere?
>>>
>>> Thank you.
>>>
>>>
>>> --
>>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-general
>>>
>>
>> It 's in pg_class!
>>
>> https://www.postgresql.org/docs/9.4/static/catalog-pg-class.html
>>
>
> But pg_class is in postgres database.
> Can I do something like this:
>
> SELECT oid FROM postgres.pg_class WHERE relname = <my_table_name>;
>
> Or I will have to connect to postgres database?
>
> Thank you.
>
>
>>
>> IOW:
>> SELECT relname, oid FROM pg_class WHERE relkind = 'r' ORDER BY 1;
>> --
>> *Melvin Davidson*
>> I reserve the right to fantasize. Whether or not you
>> wish to share my fantasy is entirely up to you.
>>
>
>

*Igor,*

*You do not need to specify "postgres" schema (postgres.pg_class). That is
wrong anyway.*

*FYI, the correct schema is pg_catalog, but All postgres CATALOGS are
always available regardless of which database you are connected to.*

*and it is in the default search path, so you do not have to specify it.*

*Just do:SELECT oid FROM pg_class WHERE relname = <my_table_name>;*

*It will work just fine! I highly encourage you to RTFM.*

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Zhu, Joshua 2017-07-13 16:09:22 Re: BDR node removal and rejoin
Previous Message Edmundo Robles 2017-07-13 15:57:46 I can't cancel/terminate query.