Re: List all tables from a specific database

From: Mladen Gogala <gogala(dot)mladen(at)gmail(dot)com>
To: Thomas Boussekey <thomas(dot)boussekey(at)gmail(dot)com>
Cc: "Ray O'Donnell" <ray(at)rodonnell(dot)ie>, Flaviu2 <flaviu2(at)yahoo(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: List all tables from a specific database
Date: 2022-01-15 05:19:11
Message-ID: CALcG2DL4kGbcQsVS8Qbyr+i4mJvVAaER04Z5xRmD53ABk4kJxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

There is also INFORMATION_SCHEMA which is SQL standard and extremely easy
to use.

On Fri, Jan 14, 2022, 1:08 PM Thomas Boussekey <thomas(dot)boussekey(at)gmail(dot)com>
wrote:

>
>
> Le ven. 14 janv. 2022 à 12:04, Ray O'Donnell <ray(at)rodonnell(dot)ie> a écrit :
>
>> On 14/01/2022 10:39, Flaviu2 wrote:
>> > I work on a project that use Postgre SQL, and I have 0 experience in
>> > this regard. I hope to get help here. I need two SQL scripts for
>> Postgre:
>> >
>> > 1. Get all databases, which I aquired already:
>> >
>> > *SELECT datname FROM pg_database WHERE datistemplate = false*
>> >
>> > This one is functional, it's ok.
>> >
>> > 2. Now, I need to find all tables *under a specific* database. This one
>> > I don't know how to achieve it. Can you help me here ? It is possible ?
>>
>
>> If it's any help, running psql with the -E switch will show you the SQL
>> which psql generates... so then (within psql) issuing the \dt command to
>> list tables will show you the SQL used.
>>
>> Ray.
>>
>> Hello,
> You can use this SQL command to view all the standard table (known as
> relations):
>
> SELECT relname FROM pg_class WHERE relkind = 'r';
>
> And this one for partitioned tables (if you use them):
>
> SELECT relname FROM pg_class WHERE relkind = 'p';
>
> HTH,
> Thomas
>
>
>> --
>> Raymond O'Donnell // Galway // Ireland
>> ray(at)rodonnell(dot)ie
>>
>>
>>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Дмитрий Иванов 2022-01-15 09:01:52 Re: [Extern] Re: postgres event trigger workaround
Previous Message Julien Rouhaud 2022-01-15 05:01:18 Re: [Extern] Re: postgres event trigger workaround