pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Igor Korot <ikorot01@gmail.com>
To: Ron Johnson <ronljohnsonjr@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Connecting pg_attribute with pg_namespace
Date: Sat, 31 Oct 2026 14:43:35 -0700
Message-ID: <92aca255-3ca3-4cb1-aec5-593b7eb3c275@aklaver.com> (raw)
In-Reply-To: <CA+FnnTyp_g2rABTzMU7Hrsk4V-UN1gmZicOuzGeqBwPOcKoesA@mail.gmail.com>
References: <CA+FnnTxQm4ppiWvW018rJ9F8ZoiEJ7sXtFbNU-r=_92_cEtJUQ@mail.gmail.com>
	<CANzqJaBbwVDh-Toan6aiPA=HKqbVk7poZ7D8VnhBDJJHwAbjAw@mail.gmail.com>
	<CA+FnnTyp_g2rABTzMU7Hrsk4V-UN1gmZicOuzGeqBwPOcKoesA@mail.gmail.com>

On 10/31/26 3:04 PM, Igor Korot wrote:
> Hi, Ron,
> 
> On Sat, Oct 31, 2026 at 1:24 AM Ron Johnson <ronljohnsonjr@gmail.com> wrote:
>>
>> Join pg_attribute.attrelid to pg_class.oid and thus you have the table's relnamespace value.
> 
>  From the docs:
> 
> [quote]
> relnamespace oid (references pg_namespace.oid)
> 
> The OID of the namespace that contains this relation
> [/quote]
> 
> I have a schema name as a string.
> 
> Should I cast that value to something when I write
> "pg_class.relnamespace = 'public'"?

Take a look at this link below:

https://www.postgresql.org/docs/current/datatype-oid.html

It will make your like easier.

So:

select relname from pg_catalog.pg_class where relname = 'cell_per' and 
relnamespace = 'public'::regnamespace;

relname
----------
  cell_per

> 
> Thank you.
> 
>>
>> On Sat, Oct 31, 2026 at 1:34 AM Igor Korot <ikorot01@gmail.com> wrote:
>>>
>>> Hi,
>>> How do I add schema name to
>>>
>>> [code]
>>> SELECT attnum FROM pg_attribute WHERE attrelid = 'my_table_name';
>>> [/code]
>>>
>>> Thank you.
>>>
>>>
>>
>>
>> --
>> Death to <Redacted>, and butter sauce.
>> Don't boil me, I'm still alive.
>> <Redacted> lobster!
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (6+ messages)  latest in thread

Message-ID: <92aca255-3ca3-4cb1-aec5-593b7eb3c275@aklaver.com>
Permalink:  ../92aca255-3ca3-4cb1-aec5-593b7eb3c275@aklaver.com/
Also on:    postgresql.org/message-id/92aca255-3ca3-4cb1-aec5-593b7eb3c275@aklaver.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, ikorot01@gmail.com, ronljohnsonjr@gmail.com
  Subject: Re: Connecting pg_attribute with pg_namespace
  In-Reply-To: <92aca255-3ca3-4cb1-aec5-593b7eb3c275@aklaver.com>
  References: <CA+FnnTxQm4ppiWvW018rJ9F8ZoiEJ7sXtFbNU-r=_92_cEtJUQ@mail.gmail.com> <CANzqJaBbwVDh-Toan6aiPA=HKqbVk7poZ7D8VnhBDJJHwAbjAw@mail.gmail.com> <CA+FnnTyp_g2rABTzMU7Hrsk4V-UN1gmZicOuzGeqBwPOcKoesA@mail.gmail.com> <92aca255-3ca3-4cb1-aec5-593b7eb3c275@aklaver.com>

* 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