From: | MichaelDBA <MichaelDBA(at)sqlexec(dot)com> |
---|---|
To: | Ron Johnson <ronljohnsonjr(at)gmail(dot)com> |
Cc: | Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org> |
Subject: | Re: PostgreSQL Database 'Information' Script - is there one out there? |
Date: | 2025-02-01 13:03:32 |
Message-ID: | ea84487e-5fea-e292-f134-72a46265a379@sqlexec.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
There are a bunch of tools, many in the form of free extensions like
pgmetrics.
Regards,
Michael Vitale
Ron Johnson wrote on 1/30/2025 9:20 AM:
> On Thu, Jan 30, 2025 at 7:14 AM Edwin UY <edwin(dot)uy(at)gmail(dot)com
> <mailto:edwin(dot)uy(at)gmail(dot)com>> wrote:
>
> Hi,
>
> Does anyone know of any existing script/s out there somewhere that
> generates some kind of database/instance inventory, like listing
> of what databases exist (\l), schema (\dn) in each databases,
> extensions (\dx), user lists (\du), replication slots, tables,
> views, parameter default/non-default settings etc?
> Maybe there is already one out there, either a shell script or a
> SQL script that I can just run from psql and save the output to file.
> At the moment, running manually via psql running \l, running \c to
> each DB and running \dn, didn't realize I have to run \dn on each
> database :(, and running select statements from pg_tables and so on.
>
>
> Why not put everything you currently do in a shell script?
>
> For per-database commands, something like this:
> export PGHOST=mumble
> export PGUSER=postgres
> DbList=`psql -AXtc "select datname from pg_database
> where datistemplate=false and datname <> 'postgres'
> order by datname ;"`
> for DB in $DbList;
> do
> psql -h $DB -ac '\dn'
> psql -h $DB -ac 'SELECT ... FROM pg_tables WHERE ...;'
> done
>
> --
> Death to <Redacted>, and butter sauce.
> Don't boil me, I'm still alive.
> <Redacted> lobster!
Regards,
Michael Vitale
Michaeldba(at)sqlexec(dot)com <mailto:michaelvitale(at)sqlexec(dot)com>
703-600-9343
From | Date | Subject | |
---|---|---|---|
Next Message | SOzcn | 2025-02-01 21:21:12 | Re: Backup Issue for pg_basebackup |
Previous Message | Hall, Michael H. (GSFC-423.0)[RAYTHEON COMPANY] | 2025-01-31 18:15:39 | Assistance with documenting a failover / fallback process that maintains replication |