In this exercise, you will use the compare editor to compare the
modified physical data model with the database source of the model. If you
had stored the data design project that contains the physical data model in
one of the supported source code management tools, you would also have the
option of comparing the local version of the physical data model with the
stored version that is under source code control.
If you make changes to a model object in the compare editor, the
changes are automatically added to the model. You must save the model to save
the changes. You can also choose not to save the changes, and generate delta
DDL statements instead.
In this exercise, you will make changes to a
server object. If you make changes to a server object in the compare editor,
you must generate delta DDL statements for the changes and deploy them to
the server to save the changes.
Before you perform the comparison, you
should refresh the database metadata in the Data Source Explorer, to ensure
that you are working with the most current information. This step is important
if you are working in a team environment, and other team members are making
changes to the database.
To compare and merge the changed physical data
model with the original schema:
- Right-click the sample Derby connection in the Data Source Explorer,
and select Refresh.
- In the Data Project Explorer, right-click the SAMP schema in the
sample_model.dbm file and select . The
compare editor opens.
- Double-click the Compare tab in the compare editor to maximize
the compare editor view. When you compare data objects, the compare
editor is customized to include a Structural Compare view and a Property Compare
view. The physical data model is displayed on the left, and the original source
from the database is displayed on the right. The columns at the top of the
Structural Compare view display the name of each object.
- Expand the data objects in the Structural Compare view to see the
changes that you made to the physical data model.
- In the Structural Compare view, navigate through each difference. You can use the Next Difference
and Previous Difference
toolbar buttons on the main toolbar to navigate or you can use the
arrow keys on the keyboard.
- Merge the changes you made to the original database source by highlighting
each difference and clicking the Copy from Left to Right
local toolbar button
in the compare editor. You can verify which row is highlighted
in the Structural Compare view by using the Property Compare view. You should
see the properties for the highlighted object.
You can also use the
compare editor to merge changes from the database server to the physical data
model, by clicking the Copy from Right to Left
local toolbar button.
- Optional: Find objects that might
be impacted by your changes by clicking the Analyze Left Impact
or Analyze Right Impact
local toolbar buttons. Because you are making changes
to the server object in this case, you must generate a DDL script to capture
the changes that you made in the compare editor.
- Click the Generate Right DDL
local toolbar button. This toolbar button is enabled only after you make changes to the right
object in the compare editor. The Generate DDL wizard opens.
- On the Save and Run DDL page, specify the following settings:
- Ensure that the EMPLOYEE data design project is specified in the Folder field.
- Type mydeltaddl.sql in the File
name field.
- Select the Open DDL file for editing check
box.
- View the generated DDL statements in the Preview DDL field.
If you wanted to run the DDL script on the server, you could select
the Run DDL on server check box. If you select this
option, you must provide connection information on the following pages of
the wizard. Your settings should now look like something
like this:
- Click Finish.
The mydeltaddl.sql file is created and displayed in the Data Project
Explorer in the
SQL Scripts folder. Because you selected
to open the file for editing, the file also opens in the SQL editor, where
you can modify the script.
After you have modified the script as needed, you can run the script
on the database server from the SQL editor by right-clicking in the editor
and selecting Run SQL.