Re: How to list all schema names inside a PostgreSQL database through SQL - Mailing list pgsql-general

From Виктор Егоров
Subject Re: How to list all schema names inside a PostgreSQL database through SQL
Date
Msg-id CAGnEboigb6ksS+ynekS1dsUYdp+8Gs8KWW9A4YZF5ajMHSxCsA@mail.gmail.com
Whole thread Raw
In response to How to list all schema names inside a PostgreSQL database through SQL  (Xiaobo Gu <guxiaobo1982@gmail.com>)
List pgsql-general
2012/11/15 Xiaobo Gu <guxiaobo1982@gmail.com>:
> How can I list  all schema names inside a PostgreSQL database through
> SQL, especially thoese without any objects created inside it.

Something like this:
select n.nspname, count(o.oid)
  from pg_namespace n
  left join pg_class o on n.oid=o.relnamespace
 group by 1
 order by count(o.oid)>0, 1;

I prefer to query PostgreSQL catalogs.
You can obtain the same information using information_schema queries.


--
Victor Y. Yegorov


pgsql-general by date:

Previous
From: Xiaobo Gu
Date:
Subject: How to list all schema names inside a PostgreSQL database through SQL
Next
From: Achilleas Mantzios
Date:
Subject: Re: How to list all schema names inside a PostgreSQL database through SQL