Re: Get table catalog from pg_indexes

From: Igor Korot <ikorot01(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Get table catalog from pg_indexes
Date: 2022-11-27 22:04:52
Message-ID: CA+FnnTw-vu8EqyoPktbGYyc=bM4Y4w4kVd3KB5P2-Pmb9iKn_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thx, Adrian.

On Sun, Nov 27, 2022 at 3:56 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> wrote:
>
> On 11/27/22 13:31, Ron wrote:
> > On 11/27/22 11:22, Igor Korot wrote:
> >> Hi, ALL,
> >> Table pg_indexes does not contain a field for a catalog.
> >>
> >> So how do I get that?
> >>
> >> SELECT 1 FROM pg_indexes WHERE indexname = $1 AND tablename = $2 AND
> >> schemaname = $3
> >
> > You did not look hard enough, or Google "postgresql pg_indexes".
> >
> > test=# \d pg_indexes
> > View "pg_catalog.pg_indexes"
> > Column | Type | Collation | Nullable | Default
> > ------------+------+-----------+----------+---------
> > *schemaname* | name | | |
> > *tablename* | name | | |
> > *indexname* | name | | |
> > tablespace | name | | |
> > indexdef | text | | |
> >
> > https://www.postgresql.org/docs/current/view-pg-indexes.html
>
> What the OP was looking for a field in the above that was catalogname or
> datname per:
>
> https://www.postgresql.org/docs/current/catalog-pg-database.html
>
> Table "pg_catalog.pg_database"
> Column | Type | Collation | Nullable | Default
> ---------------+-----------+-----------+----------+---------
> oid | oid | | not null |
> datname | name | | not null |
> ...
>
> In other words to filter the pg_index results by database/catalog name.
> Since pg_index is scoped to the database you are in when you do the
> query that is not going to happen.
>
> >
> >
> >
> >
> > --
> > Angular momentum makes the world go 'round.
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2022-11-27 22:10:19 Re: Get table catalog from pg_indexes
Previous Message Adrian Klaver 2022-11-27 21:55:48 Re: Get table catalog from pg_indexes