Re: List all tables from a specific database - Mailing list pgsql-general

From Julien Rouhaud
Subject Re: List all tables from a specific database
Date
Msg-id 20220114122609.y3h5wcleromhvbn4@jrouhaud
Whole thread Raw
In response to Re: List all tables from a specific database  (Flaviu2 <flaviu2@yahoo.com>)
List pgsql-general
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)



pgsql-general by date:

Previous
From: Flaviu2
Date:
Subject: Re: List all tables from a specific database
Next
From: Flaviu2
Date:
Subject: Re: List all tables from a specific database