HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlCritical

How do I list all schemas in PostgreSQL?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlallschemashowlist

Problem

When using PostgreSQL v9.1, how do I list all of the schemas using SQL?

I was expecting something along the lines of:

SELECT something FROM pg_blah;

Solution

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

Code Snippets

select schema_name
from information_schema.schemata;
select nspname
from pg_catalog.pg_namespace;

Context

StackExchange Database Administrators Q#40045, answer score: 435

Revisions (0)

No revisions yet.