In Postgresql these terminal commands list the databases available
el@defiant$ /bin/psql -h localhost --username=pgadmin --list
Or the command stated more simply:
psql -U pgadmin -l
Those commands print this on the terminal:
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
kurz_prod | pgadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
pgadmin | pgadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(5 rows)
These are the available databases.
In PSQL these commands list the tables available
You have to specify a database before you can list the tables in that database.
el@defiant$ psql -U pgadmin -d kurz_prod
This brings you to a psql terminal:
kurz_prod=#
Use the command \d
meaning show all tables, views, and sequences
kurz_prod=# \d
This prints:
List of relations
Schema | Name | Type | Owner
--------+---------+----------+---------
public | mytable | table | pgadmin
public | testing | sequence | pgadmin
(2 rows)
Then, to exit the psql terminal, type \q
and press enter. Or Ctrl-D
does the same thing. These are the tables in that database.