Search Postgresql Archives

Re: List all tables from a specific database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux