Schema Compare
Schema Compare compares two databases, say development and production, and generates a script that brings one in line with the other. Schema Compare in the header opens it.
Comparing
- Choose the Source: connection and database with the desired state, usually development.
- Choose the Target: the database with the current state that should be adjusted.
- Click Compare.
What gets compared:
- Tables with columns, indexes, foreign keys and check constraints
- Code objects: views, procedures, functions and triggers
The summary at the top says how many objects are new, modified, removed and identical.
The result list
Every object carries a label:
| Label | Meaning |
|---|---|
| source only | missing in the target, will be created |
| target only | no longer in the source, will be removed |
| changed | differs |
| identical | the same |
Hide identical and Filter… keep the list manageable. Clicking an object shows the difference side by side: Target (current) on the left, Source (desired) on the right.
Sync script
Generate sync script opens a script in a new tab, connected to the target database. It works in a sensible order: first drop foreign keys and indexes, then drop removed objects, create new ones, alter columns, and finally recreate foreign keys, indexes and constraints.
Multi-part changes are wrapped in BEGIN TRANSACTION. COMMIT and ROLLBACK are commented out: run it, check the result, then deliberately run COMMIT or ROLLBACK.
Read the script before running it. "Target only" objects in particular get dropped, and for tables that means: including their data. On a production database, take a backup first.