Re: [GENERAL] Get table OID

Поиск
Список
Период
Сортировка
От Melvin Davidson
Тема Re: [GENERAL] Get table OID
Дата
Msg-id CANu8FixnW+_ph0MEdgCOUrAyzo68sKavU=zKfWX==PdJoFRyLQ@mail.gmail.com
обсуждение исходный текст
Ответ на [GENERAL] Get table OID  (Igor Korot <ikorot01@gmail.com>)
Список pgsql-general


On Thu, Jul 13, 2017 at 11:06 AM, Igor Korot <ikorot01@gmail.com> wrote:
Hi, Melvin,

On Thu, Jul 13, 2017 at 10:42 AM, Melvin Davidson <melvin6925@gmail.com> wrote:

On Thu, Jul 13, 2017 at 10:36 AM, Igor Korot <ikorot01@gmail.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@postgresql.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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Edmundo Robles
Дата:
Сообщение: [GENERAL] I can't cancel/terminate query.
Следующее
От: "Zhu, Joshua"
Дата:
Сообщение: Re: [GENERAL] BDR node removal and rejoin