Lijst de databases in een PostgreSQL-instantie
Gepubliceerd op 30 July 2019
Ik heb geen zin om te installerenhttps://www.pgadmin.org/[pgAdmin] ou phppgadmin terwijl alles aanwezig is op de opdrachtregel
Daarvoor moeten we de terminal starten en inloggen als de postgres-gebruiker.
de user postgres is de enige die standaard het recht om de applicatie psql te starten heeft, die de opdrachtregelclient is (CLI) postgresql,
om met de database via de commandoregel vanaf de terminal te kunnen communiceren
Om verbinding te maken, open de terminal en typ dit:
$ sudo -i -u postgres
Om verbinding te maken en direct naar de PostgreSQL-opdrachtprompt te gaan, typ dit:
$ sudo -i -u postgres psql
Om de databases van een PostgreSQL-instantie op te lijsten, hier is de opdracht :
postgres=# \l
resultaat:
Lijst van databases Naam | Eigenaar | Codering | Collatie | Karaktertype | Toegangsrechten
fiber | tech | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =Tc/tech
| | | | | tech=CTc/tech fiberdev | tech | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =Tc/tech
| | | | | tech=CTc/tech fiberweb | tech | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =Tc/tech
| | | | | tech=CTc/tech postgres | postgres | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | template0 | postgres | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =c/postgres
| | | | | postgres=CTc/postgres template1 | postgres | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =c/postgres
| | | | | postgres=CTc/postgres (6 lignes)
Druk q om de resultaten weergave te verlaten
om de schema’s van een instantie van postgresl op te lijsten
postgres=# SELECT schema_name FROM information_schema.schemata;
resultaat
openbaar information_schema pg_catalog pg_toast_temp_1 pg_temp_1 pg_toast (6 regels)
ou
postgres=# SELECT nspname FROM pg_catalog.pg_namespace;
resultaat
pg_toast pg_temp_1 pg_toast_temp_1 pg_catalog information_schema openbaar (6 lijnen)