Re: Is there a "right" way to test if a database is empty? - Mailing list pgsql-hackers

From Graham Leggett
Subject Re: Is there a "right" way to test if a database is empty?
Date
Msg-id 5B09CFC6-EE9D-4483-84B6-FB1393CD3041@sharp.fm
Whole thread Raw
In response to Re: Is there a "right" way to test if a database is empty?  (pinker <pinker@onet.eu>)
List pgsql-hackers
On 17 Jan 2018, at 6:01 PM, pinker <pinker@onet.eu> wrote:

I always do: \l+ and then you can compare the size: new_one | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 7869 kB | pg_default | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +| 7869 kB | pg_default | | | | | postgres=CTc/postgres | | | template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +| 7869 kB | pg_default

What I am after is something scriptable and data safe.

The size isn’t something I would be comfortable relying on.

Regards,
Graham

Attachment

pgsql-hackers by date:

Previous
From: pinker
Date:
Subject: Re: Is there a "right" way to test if a database is empty?
Next
From: Corey Huinker
Date:
Subject: Re: CREATE ROUTINE MAPPING