I would like to create an app in Toad that generates an "ALTER TABLE" script for existing tables across different schemas. Can I do this using the Automation Designer? And if so, how?
My approach would be to generate individual scripts within a loop using the "Compare Schemas" action and then write those scripts to a single file. Something like this:
If you want to compare tables in schemas A, B, C in one database to schemas A, B, C in another database, you can set up schema compare like this (uncheck "Match schemas automatically" if you want to choose the source and target pairs yourself):
Toad will create separate scripts for each comparison, but also a "MasterScript.SQL" which calls all of the other scripts. So it's not one big script, but it's only one script that you need to call.
Thanks for the quick reply. Is this a new feature? It’s the first time I’ve seen that you can compare multiple schemas. Cool. Maybe this is what I was looking for. But how do I set the filter for more then one schema?
Compare multiple schemas has been there for several versions, but it's easy to miss.
That filter does support multiple like A%;B%
Here, I have set it for T%;J%;B%.
Edit: I just found a bug here. If the schema filter is already set when you choose a target connection, the filter gets incorrectly used in your SQL (without breaking it up by the semicolons). Please set the filter AFTER choosing your target schema. I will fix this for next beta.
When "Match Schemas automatically" is unchecked, then the checked schemas in the grid is what will be compared. So I could uncheck some of them if I want and they would be left out of the comparison.
Also, If I want, I can manually choose a target schema (maybe it doesn't have the same name as source), and then check the "Include" box in that row.
Then Toad will compare whatever is checked in the grid.
When "Match Schemas automatically" is checked, then Toad will check the filter at runtime and find schemas in both databases with matching names to compare.
If you click Next a few times you will see a list of the schemas that will be compared as it's getting started.
Note: If you close and re-open schema compare, then the previous compare gets reloaded. In this case, the non-compared schemas are not present in the grid.
I really need a "refresh" button in there so you can re-add the the non-compared schemas more easily, but you can re-add them by changing to a different target connection, and then changing it back to the one you want.