How do I list all schemas in PostgreSQL?
To lists all schemas, use the (ANSI) standard INFORMATION_SCHEMA
select schema_name
from information_schema.schemata;
More details in the manual
alternatively:
select nspname
from pg_catalog.pg_namespace;
More details about pg_catalog in the manual
When using the psql
command line, you may list all schema with command \dn
.
Connect to the psql command --> psql --u {userName} {DBName} then you can type the below command to check how many schemas are present in the DB
DBName=# \dn
Else you can check the syntax by the below steps easily-
After connecting the the DB, press
DBName=# help
You will get the below options:
You are using psql, the command-line interface to PostgreSQL.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
Then press
DBName=# \?
You will get all the options very easily.