Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uozKy-00EDSs-TR for pgsql-admin@arkaria.postgresql.org; Thu, 21 Aug 2025 07:03:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uozKx-00EgEn-DX for pgsql-admin@arkaria.postgresql.org; Thu, 21 Aug 2025 07:03:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uozKx-00EgEf-04 for pgsql-admin@lists.postgresql.org; Thu, 21 Aug 2025 07:03:51 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uozKv-0013Dx-11 for pgsql-admin@lists.postgresql.org; Thu, 21 Aug 2025 07:03:51 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-76e2e88c6a6so639449b3a.1 for ; Thu, 21 Aug 2025 00:03:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755759826; x=1756364626; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=ukeBsjslVH5c/cxM1+MxuT5rVDhadpdQI5ZgqaLxL1s=; b=TDMuW5hX0ghhjNuzGj2TW37yLliYUEN8n21131vWHcLkrCrrP7pbagKRPhDdIdUXci 6M6KAFZ4LiqP3yFpTZDGyHem4OrBBZN0JIrS7T9xTf6xhOfzewz1bXA/kqm64dLHMriq NIL+zujAjPwYAFOQfP2shwcu6GiYJ3anGjFI37KZKSKNoPUEqAr3IVHjpmkWrWdimMcj S9quuBRr3golBm6zPE8hi9fFw4xAUT1i5nABtC18jrEQtLtrsamRJLfzNEnKtNRqWixt 32EO6EdCkJhKyXLPfC+2WV/WTRjjU3fTnBbRKLXhh7n47l/0nizSpcGO95H3610+H1I6 UTIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755759826; x=1756364626; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ukeBsjslVH5c/cxM1+MxuT5rVDhadpdQI5ZgqaLxL1s=; b=NP67R52bjWWZkDPdhrTHet/nPrYJKqplZV89aqA1tAHu/xKHabkKq+bEGW0SQIlubE vCkH5gV/whRabxRh6tljkjHTlF4okrnEDDzwMUTAJJhmlwWuxKZ4RTXYsC5+HmaINYjO oXpgvshA5W6/GGM/qNd1SEMUwjjnRy9MwPp/OAekCzM1RKYjvP5S0Y9v7DPp9rXeYYR7 Y6DUpl8fHKhK4hPbl5FKjBWKKsN+2y/HjtDTH0lvTUFf2VTc5e71nccYV1pXagbA1le4 vRUy3CyuRrAVYU1GlgFuhsiRFPIGcXJ+hLqWli/ctnSpPvqqG8sg0EeyDYAo8RPhDcx3 eJww== X-Gm-Message-State: AOJu0YwpHYhyTTgysDgcjUVP6MZulwVjxuHvaCHQHPFIcGucVOVRSLK4 /RSk/X5TTqh9j62G7Nf9RAv/Jhn5+KFOeTGL9202JDH3vo/pXC5RHqRiqPAl2fQcPSUynyg8Q66 Nb4Z+IMsHFVyheNqf3UhLwrL2PyxsAQi9VD2eMjA= X-Gm-Gg: ASbGnctV9W3swu3BiJIHkYLVSFdzgmUHA7CtVPGcEFPzu/t6DoelF0tdjqZRtejo7Ee a5SZBvUBa0rYFvqnbrxHMVgBy6iaSY/xpyYD5h274NMWl2oss6zxvDHycKpcwY2hA1/MAJWMA6d ZEFRwnx/6bUr/+nVn1lS+n34PSpUKGcQGO6RXkKcl4RQOqTKoTxmuiVBlPa8Ujf60vpAAmWq4fW jeiCHu+SAKpdfra5g== X-Google-Smtp-Source: AGHT+IFdhXA/daAP50syPoXDLwC+7Z2a17J3gBnYlb6bLcyb8wRjFFNpzkkhHH0uet/NCXksp/93d9ad9RFITZCG4hE= X-Received: by 2002:a17:903:4b07:b0:240:934f:27ac with SMTP id d9443c01a7336-245fed7d1e0mr19258735ad.33.1755759826305; Thu, 21 Aug 2025 00:03:46 -0700 (PDT) MIME-Version: 1.0 From: Edwin UY Date: Thu, 21 Aug 2025 19:03:09 +1200 X-Gm-Features: Ac12FXyDJhjLWvCGvFjhMyQPwaYJrLULXr5T2RH_flAa5EaMbHKgBRvPiKcGoZI Message-ID: Subject: SHELL Script to Compare Database Tables / Indexes / Constraints To: Pgsql-admin Content-Type: multipart/alternative; boundary="000000000000c207f5063cdab051" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c207f5063cdab051 Content-Type: text/plain; charset="UTF-8" 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 --000000000000c207f5063cdab051 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

Hoping to be 'lucky&= #39; here.
Anyone aware=C2=A0of any shell script/s that can list = all tables / indexes / constraints for 2 DBs and compare them for any diffe= rences? I am only wanting to compare the structure, not the data.
Found some from browsing around, pgcmp, pgdiff, but the problem is I am no= t allowed to install stuff on the server. The DB version, 11.7, is really o= ld 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 ind= ex to a file of their own
- doesn't there is a \ version for constraints but I think I can d= o select from pg_constraints for list of constraints and output each constr= aint to a file of their own
- compare/diff the file content of ea= ch file
- will start with just the tables for now

Regards,
Ed

--000000000000c207f5063cdab051--