List schemas in Redshift

Query below lists all schemas in Redshift database. Schemas include default pg_* , information_schema and temporary schemas.

If you want to list user only schemas use this script.

Query

select s.nspname as table_schema,
       s.oid as schema_id,  
       u.usename as owner
from pg_catalog.pg_namespace s
join pg_catalog.pg_user u on u.usesysid = s.nspowner
order by table_schema;

Columns

  • table_schema - schema name
  • schema_id - schema id, unique within the database
  • owner - principal that owns this schema

Rows

  • One row represents one schema in a database
  • Scope of rows: all schemas in a database, including default ones
  • Ordered by schema name

Sample results

Here is a view of database schemas in DBeaver.