I was wondering if there is an established way to test if two PostgreSQL tables/relations have the same structure. In other words, how to test whether they are compatible with each other in the sense that I can perform set operations such as UNION ALL and EXCEPT on them?
I searched around on DBA.SE and elsewhere, and can only find questions about finding whether the contents of two tables are different, (e.g. Checking whether two tables have identical content in PostgreSQL), or when the compatibility is known (e.g. Compare two tables with same structure, but differing membership numbers). But I'm interested in checking the compatibility of table structure.
I'm using PostgreSQL 10.3, but standard compliant ways are certainly preferable.
fieldof some type matched thefield1orfield2of the same type without additional info about that fields. 2)UNION ALLandEXCEPTdo not require to use all of table's fields, You can select only a part of them while reminders maybe not equivalent. To obtain table structures is not difficult while to compare them automatically may be unsolvable. – Akina May 17 '18 at 06:02*(inclusive of all columns). Or compatability of a subset of the columns based on their type. – Evan Carroll May 17 '18 at 17:47