public inbox for [email protected]
help / color / mirror / Atom feedFrom: Edwin UY <[email protected]>
To: Pgsql-admin <[email protected]>
Subject: SHELL Script to Compare Database Tables / Indexes / Constraints
Date: Thu, 21 Aug 2025 19:03:09 +1200
Message-ID: <CA+wokJ-s562t8R4bVP225EeX+2n1iFBxsb8=O=ZTW-qzCtfBWw@mail.gmail.com> (raw)
Hi,
Hoping to be 'lucky' here.
Anyone aware of any shell script/s that can list all tables / indexes /
constraints for 2 DBs and compare them for any differences? I am only
wanting to compare the structure, not the data.
Found some from browsing around, pgcmp, pgdiff, but the problem is I am not
allowed to install stuff on the server. The DB version, 11.7, is really old
too so not sure whether these ones I found will work.
There is also one that uses pgdump and pg_restore -l to do the comparison.
I am looking at something like below:
- connect to db01 and db02
- \dt - select from pg_tables for list of tables and output each table to a
file of their own
- \di - select from pg_indexes for list of indexes and output each index to
a file of their own
- doesn't there is a \ version for constraints but I think I can do select
from pg_constraints for list of constraints and output each constraint to a
file of their own
- compare/diff the file content of each file
- will start with just the tables for now
Regards,
Ed
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: SHELL Script to Compare Database Tables / Indexes / Constraints
In-Reply-To: <CA+wokJ-s562t8R4bVP225EeX+2n1iFBxsb8=O=ZTW-qzCtfBWw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox