From: Flaviu2 <flaviu2@yahoo.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: List all tables from a specific database
Date: Fri, 14 Jan 2022 10:39:29 +0000 (UTC)
Message-ID: <754992290.610416.1642156769536@mail.yahoo.com> (raw)
References: <754992290.610416.1642156769536.ref@mail.yahoo.com>
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 ?
For instance, using this SQL script:
SELECT 1, datname FROM pg_database WHERE datistemplate = false
I got:
mydb1mydb2postgres
So far, so good. Of course, mydb1 and mydb2 have been created by me, using:
create database mydb1create database mydb2
Now, which SQL script to use, to retrieve all tables under a database only, but, most important, using SQL script only.
For instance, something like (pseudo-script):
SELECT table_name FROM information_schema.tables WHERE database = 'mydb1'SELECT table_name FROM information_schema.tables WHERE database = 'mydb2'
Kindly thank you.
Flaviu.
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: flaviu2@yahoo.com
Subject: Re: List all tables from a specific database
In-Reply-To: <754992290.610416.1642156769536@mail.yahoo.com>
References: <754992290.610416.1642156769536.ref@mail.yahoo.com> <754992290.610416.1642156769536@mail.yahoo.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