From: Julien Rouhaud <rjuju123@gmail.com>
To: Flaviu2 <flaviu2@yahoo.com>
Cc: Ray O'Donnell <ray@rodonnell.ie>
Cc: Thomas Boussekey <thomas.boussekey@gmail.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: List all tables from a specific database
Date: Fri, 14 Jan 2022 20:26:09 +0800
Message-ID: <20220114122609.y3h5wcleromhvbn4@jrouhaud> (raw)
In-Reply-To: <885647530.630187.1642162768711@mail.yahoo.com>
References: <754992290.610416.1642156769536.ref@mail.yahoo.com>
<754992290.610416.1642156769536@mail.yahoo.com>
<424c1084-1e65-8e06-7f80-efe2a2b819e7@rodonnell.ie>
<CALUeYmfm5ASkR4c60jy9zX0wEQxtBOhZYoOa=LtBP_OSBr9jKg@mail.gmail.com>
<885647530.630187.1642162768711@mail.yahoo.com>
Hi,
On Fri, Jan 14, 2022 at 12:19:28PM +0000, Flaviu2 wrote:
> Thanks a lot.
> Maybe I am not far from a solving solution. So, if I create a database, lets say (SQL script):
> CREATE database mydb3;
> How can I create a table under mydb3 ? Because, if I run:
> SELECT relname FROM pg_class WHERE relkind = 'r';
>
> Got me all tables, but I don't know the database under were created.
On postgres all relations, functions and so on are specific to a specific
database, and only accessible when connected on that specific database.
So if you want to create a table in mydb3, or see the list of tables in that
database, you need to connect to mydb3.
If needed, you can get the current database with the current_database()
function, e.g.:
=# SELECT current_database();
current_database
------------------
postgres
(1 row)
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: rjuju123@gmail.com, flaviu2@yahoo.com, ray@rodonnell.ie, thomas.boussekey@gmail.com
Subject: Re: List all tables from a specific database
In-Reply-To: <20220114122609.y3h5wcleromhvbn4@jrouhaud>
References: <754992290.610416.1642156769536.ref@mail.yahoo.com> <754992290.610416.1642156769536@mail.yahoo.com> <424c1084-1e65-8e06-7f80-efe2a2b819e7@rodonnell.ie> <CALUeYmfm5ASkR4c60jy9zX0wEQxtBOhZYoOa=LtBP_OSBr9jKg@mail.gmail.com> <885647530.630187.1642162768711@mail.yahoo.com> <20220114122609.y3h5wcleromhvbn4@jrouhaud>
* 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