So you’ve been working on your data model, and you’re wondering how far ‘out of whack’ it is with the production or development database instance. Sometimes folks manage to compile changes into the database, bypassing your design process and rules.
If you’re wondering how to compare 2 models instead of your model with the database, read this.
So your question is basically, show me what’s different. You just need to decide what version of the ‘truth’ to adhere to:
- the database
- the model
You need to make this call as the comparison results include DDL scripts to bring the system into alignment.
But Wait, Those Buttons Are Greyed Out For Me!
To compare your model with the data dictionary, we need to know where that data dictionary is. If you add the model objects from a data dictionary, the connection information is ‘known’ to the model. If you look at one of your model object’s properties, you can see if it’s ‘tied’ to a database:
Filtering and Selecting Your Results
The comparison dialog will come back with your results. You can review the differences and ‘approve’ the findings by checking those items in the tree. Key things to check are the ‘Tables that will be recreated’ and the ‘Options’ panels. Some object alters might not be possible without dropping and re-creating the table. Additionally, the ‘options’ panel allows you to decide exactly what properties to compare or not. This will have a dramatic impact on the type of DDL scripts the compare will generate.
Applying the Scripts
There’s no ‘go make it happen’ button in the modeler. You’ll have to take the generated script, test it, tweak it, and approve it. Then you’ll need to run it against your database either via SQL*Plus or SQL Developer. Looking for a ‘apply’ button that will automatically execute the script against your database? Share your thoughts in our Exchange with your enhancement requests. Personally, I think this would be ‘dangerous,’ but I see that many other modeling tools offer this feature, so maybe I’m just too paranoid.
But I Only Want to Compare a Few Things, Not Everything!
Ok, so your model is huge, and you don’t care about ‘everything’ right now. You have three levels of compare ‘depth’ to choose from:
- Compare everything
- Compare just the SubView
- Compare just selected objects
You already know how to compare ‘everything’ – just use the main toolbar ‘Synchronize’ buttons.
Compare Just the SubView
SubViews are great. They allow you to break your model into one or more ‘mini’ models. If you do a data dictionary import from multiple schemas, SQL Developer will automatically generate a SubView for each schema. If you only wanted to synchronize/compare just one schema in your model, then the SubView compare would be the easiest way to go.
To kick off the synchronize, go into the subview, and right-click in the subivew diagram.
Compare Just Selected Model Objects
Just what it sounds like, if you want a quick-and-dirty compare, just select or multi-select the object(s) in the diagram, right click and ‘Synchronize…’
Again, don’t forget to check, check, and check again your options. Then make sure to test your scripts before you just run them against your DEVELOPMENT or TEST databases. I’m not even going to mention PRODUCTION, because you already know better.
One last word about options – you can say in the preferences what pieces of the PHYSICAL model properties to apply in your compares. By default we only take in the tablespaces and sequences from that level. So if you’re wondering why your synonyms or PL/SQL objects aren’t being compared and ‘synched’, then go to the preferences and toggle them on.
When the DDL gets generated, it would be nice to have some separation between tables in the DDL. When needing to go through the DDL, it would make things much easier to read.
You mean, blank lines?
So I am wondering why my triggers aren’t being compared and ‘synched’, and triggers are not available in the preferences to toggle. What am I missing? I want to use the Compare Models tool and grab trigger changes, along with say column changes which do show as alter statements to tables, for example. Thanks in advance for any help!! (This is my first question to you, thanks That Jeff Smith.)
Is your physical model open? If it’s not open, I don’t think we’ll pick up the triggers in the compare…to be honest, I’ve not used the modeler to compare triggers before.
So that’s one of the things I notice…how to open the physical model. I notice I need to refresh when navigating to the physical model to get that dropdown list to show.
Generally, I am trying to use data modeler to generate the DDL of all changes since the last release…so I save the model each release. If triggers change, I want to get those changes. Seems like the tool should do it, yes?
AH! so I had checked that Don’t show this dialog when opening a model and the first time I didn’t have physical checked! Seems like there should be a way to open the physical model in another way.
However, having the physical model open does not appear to help get the trigger changes.
Yeah, I think so. Can you submit a question to our forums, including a use case and the type of change you’re trying to detect?
I’m using 184.108.40.2063 with the personal edition install. I’m doing small project at home to test for things at work where we have an enterprise version. When I compare my model with the database and try to use the “Sync New Object” button nothing happens on my database. What could the cause be? I tried this at work and thought I’d try here at home to see if maybe I don’t have the right permissions at work. Nothing is working.
That button doesn’t touch your database.
What it does, is it updates your model if you have made any changes to objects you’ve imported from your data dictionary, or if you’ve added new objects so that the compare will treat those objects as if they came from your database.
So, if you have done a data dictionary import, then changed a table name. Or added a new table. Or added a column – those objects, after touching that button, will be marked as having come from the database, so when you do the compare, they are compared to the corresponding schema from where the original import was performed.
We’re going to rename that button label and add a tooltip so this is more obvious.
If you want to actually sync your database, hit the ‘Merge’ button and take the generated DDL script and execute it against your database – AFTER you have reviewed and tested it of course.
I’m trying to get my model to synchronize with my oracle data dictionary. I imported the table into my model so the source information is in the table properties. I added a new field to the table and then I right clicked on the table and chose sync with data dictionary. The problem is that Sync new objects doesn’t do anything and Merge is disabled. My only option is DDL preview and run them manually. In a prior version (version 3), I was able to push all my model changes into oracle, however, since using the newer versions (4 or higher), this hasn’t been working. It’s not clear as to what step I’m missing to get the merge button enabled.
Hello — this sounds like the same problem I’m having. When I attempt to sync my model with the MSSQL db, the ‘Merge’ and ‘DDL Preview’ buttons are both greyed out (even though SDDM correctly displays the differences/deltas in the upper portion of the dialog). Any thoughts on this?
Thanks so much,
ALTER SCRIPTING isn’t available for databases not named ‘Oracle’
Almost two years passed since this your reply but the limit seems to be still there. Is it still not possible to have alter scripting for DB not named Oracle?
Thanks for you posts.
Correct. Our focus is Oracle.
I’m having issues/problems generating DDL scripts for synonyms. As you mentioned in this thread, I did change my Preferences (Preferences > Data Modeler > Model > Synchronization Physical > Oracle) and checked SYNONYM. But still, SDDM does not generate those DDL scripts for synonyms. I’m baffled!
Using SQL Developer Data Modeler (or SDDM) v4.0.2.
Up at my in-laws for the Holidays and don’t have my work computer out, but make sure the physical model is actually open. If it’s not, the modeler doesn’t use the information there to generate the DDL scripts.
unfortunately I have the same problem as Steph. Synchronizing the Data Dictionary with the model skip synonyms and also funciotns/procedures. Even though the preferences for physical synchronizations are set and the physical model is actually open.
Using SQL Developer version 220.127.116.11 (with Oracle SQL Developer Data Modeler version 18.104.22.1686)
I would post this to the forums – I’m assuming there are no errors in the import logs?
Perhaps dashes or something else. Maybe a ‘header’ with table name?
You’re need to write a custom DDL transformation script (Tools – Design Rules & Transformations – Tabld DDL Transformations) …something like this
there’s also a DDL option in preferences to include a PROMPT, which adds a SQL*PLus doc style PROMPT command between each object creation.
I have a Q. I have Imported my DD to SQL Developer and I have my ER etc etc. I have SEQ’s for PK’s basically in all my tables, when I do DDL view for one table the SEQ create is NOT there ( I have enabled the generation trigger flag and set name for the SEQ and TGR). If I create a NEW table and set everything the SEQ create command is added to DDL view. Why? I would like to see the SEQ create command for the tables I have imported. Any clues?
Thanks in advance,
The sequence isn’t actually part of the table. The only thing linking the sequence to the column is the trigger. The data dictionary doesn’t know that the column value being generated is coming from INSIDE THE DATABASE 🙂
We would have to parse the trigger source to know this.
So, it’s a challenge.
Until 12c, when you can create the column as IDENTITY.
I understand and I am not expecting to have the SEQ tied to the table when the Schyn is done, but after this, I have entered the SEQ name to the table imported and the DDL generated does not include the CREATE SEQ statement. is this a bug?
DDL preview on a table only shows the DDL for the table. A sequence isn’t defined as being part of a table. If you generate the DDL for the entire model, you’ll see the sequence then.
I have a question regarding the SQL dev data modeler , Model synchronization to DB.
If you bring your model from Oracle DEsigner, how can you tie it to a DB, so when you synchronize with DB, it knows to which DB comparing.
So far it only way, is to import some objects from the data dictionnary such as schemas, users and tablespace, then I do an import from Oracle DEsigner, to finally merge them.
Is this the only way?
Thanks in advance.
No, in the latest version, 3.3, we added the ability to redirect the data dictionary compare back to another connection.
See this post for details