I have been unable to find a solution in my searching for this throughout the web, most responses recommend a tool, which leads me to believe this may be very difficult with an SQL query or something, but...
I have been told to write a query for our DB2 database, using Toad to interface, that will compare 2 schemas and provide a result if there are any differences. I know this capability exists in Toad, but for some reason our DBA does not want to use it. Purchasing additional software is not an option.
I have very limited SQL knowledge/experience, and this is one of my 'learning' tasks. I have not made much progress and am feeling very stuck. Can anyone offer me suggestions? The help is greatly appreciated!
I assume by schemas you mean the schemas of a table, right? All that information is available through the views of the
syscat
schema. Look for instance atSYSCAT.TABLES
andSYSCAT.COLUMNS
, or see the documentation for more. You can query those views like any other view/table, so to compare if two tables contain the same columns, you can do something like:This will, for instance, not return all the columns that are in tab1, but not in tab2.