Re: List all tables from a specific database

Поиск
Список
Период
Сортировка
От Julien Rouhaud
Тема Re: List all tables from a specific database
Дата
Msg-id 20220114122609.y3h5wcleromhvbn4@jrouhaud
обсуждение исходный текст
Ответ на Re: List all tables from a specific database  (Flaviu2 <flaviu2@yahoo.com>)
Список 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 по дате отправления:

Предыдущее
От: Flaviu2
Дата:
Сообщение: Re: List all tables from a specific database
Следующее
От: Flaviu2
Дата:
Сообщение: Re: List all tables from a specific database