V
V
Vladislav Khvostov2017-04-06 12:17:20
MySQL
Vladislav Khvostov, 2017-04-06 12:17:20

Get a list of tables of a particular postgres database?

There are several databases, you need to display all tables for a specific database (by name). Please help me make a request.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Korotkov, 2017-05-09
@smagen

This query will list the table names (as well as the schema names where they are located) for the current database.

SELECT n.nspname, c.relname
FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind = 'r' AND n.nspname NOT IN('pg_catalog', 'information_schema');

It is impossible to view the list of tables of another database (not the one to which it is connected). You need to connect to each database separately.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question