Re: Is there a "right" way to test if a database is empty?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Is there a "right" way to test if a database is empty?
Дата
Msg-id CAKFQuwba99R+y9VOEfS-yFV4p_vDos4bx5CQakuHP1jCWP2Ecw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Is there a "right" way to test if a database is empty?  (Graham Leggett <minfrin@sharp.fm>)
Список pgsql-hackers
On Wed, Jan 17, 2018 at 9:39 AM, Graham Leggett <minfrin@sharp.fm> wrote:
Would it be true to say that if this query returned more than zero rows the database is not empty?

db=# select distinct s.nspname from pg_class c join pg_namespace s on s.oid = c.relnamespace where s.nspname not in ('pg_toast','information_schema','pg_catalog');
 nspname 
---------
 public
(1 row)

​Depends on how you want to define empty.  You indicated "after createdb" and createdb creates the public schema.

David J.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Graham Leggett
Дата:
Сообщение: Re: Is there a "right" way to test if a database is empty?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Unnecessary static variable?