Applies to
ApexSQL Diff and ApexSQL Diff for MySQL
Summary
This article explains how to use filtering options in ApexSQL Diff and ApexSQL Diff for MySQL to narrow down database schema comparison and synchronization to affected objects only.
Description
In cases when database schema comparison and synchronization need to be narrowed down to desired objects, ApexSQL Diff and ApexSQL Diff for MySQL offer various filtering options. Additionally, these filtering options can reduce the comparison and synchronization time, and size of the schema synchronization script.
ApexSQL Diff and ApexSQL Diff for MySQL offer the following filtering options that can be divided in two groups:
- The pre-comparison filter options:
- The Object filter options – filter object types and individual objects
-
The post-comparison filter options:
- The Object filter – filter objects by difference type and object type
- The Filter editor – filter object types by schema and object name conditions
- The Difference filter – filter objects differences based on several attributes
- The Results grid column filters – filters out columns in the Results grid
- The Object filter – filter objects by difference type and object type
Pre-comparison filtering
Once the source and destination data sources are set in the New project window, expand the Advanced options and click the Object filter tab:
In the Object filter tab, all SQL and MySQL Server object types will be shown and by default all of them are checked:
|
Quick tip: If none of the Object filter options isn’t used, all object types and individual objects will be included in the comparison and synchronization process |
The following filtering can be applied in the Object filter tab:
- Check/uncheck the checkbox on the left side of the object type, to include/exclude specific object types:
-
When the object type node is clicked in the left panel, a list of available objects for the selected object type is displayed in the grid and by default, all objects are checked. There are five ways to filter individual objects:
- Manually check/uncheck individual objects in the object list:
-
Column filtering of the object list offers three ways of filtering:
-
Filter checked/unchecked objects in the list with the Show only checked/unchecked objects buttons above the object list:
-
Filter object list by using the filter for the Name column, by using the
Values or Text filters tabs 1: - Filter object list by using the filter for the database Schema column, by using the Values or Text filters tabs:
-
Filter checked/unchecked objects in the list with the Show only checked/unchecked objects buttons above the object list:
-
The Filter editor feature can filter out the object list by using multiple conditions, so that specific objects are shown. To initiate the Filter editor window, click the Edit filter button in the top-right corner of the Object filter tab 2:
|
Quick tip: Object filtering may speed up the comparison process, but ApexSQL Diff and ApexSQL Diff for MySQL cannot detect dependent objects if they are excluded from the comparison, which may result in error(s) during the synchronization process |
Post-comparison filtering
The comparison results displayed in the Results grid can be filtered using:
- The Object filter – allows users the following filtering:
- To filter objects shown in the Results grid by their difference type, the following checkboxes can be used:
- Different – displays objects that exist in both the source and the destination, but there are differences in their structure
- Missing – displays objects that exist only in the source
- Additional – displays objects that exist only in the destination
- Equal – displays objects that exist in both the source and the destination, but their structure is equal
- Filtering of object types shown in the Results grid can be done by selecting the object type checkboxes in the Object filter:
Grouping options can be used to choose in what order object types will be displayed in the Object filter and for easier viewing 3.
-
The Filter editor is used for the specific filtering when setting up a schema or name condition for an object type. For example, the database schema comparison results are shown in the Results grid and there is a need to see only tables with schema name Production and that objects name contains word Product:
To set the condition with the Filter editor, select the Tables object type in the Object filter panel and click the Filter button next to it:
The Filter editor window is shown and criteria can be set to And/Or or to Not And/Not Or, to display objects that meet the condition:
The filter criteria can be built by using the drop-down menu for each field and by using the to add a condition or to remove it. As mentioned above, the filter criteria will be set that object name contains word Product and schema name is Production:
After setting up the filter criteria and the OK button is clicked, the Results grid will show tables that only meet the previously set filter criteria:
Filter management options in the Object filer panel allow to save the current filter settings for later use, open saved ones or clear current object filter selection:
- To filter objects shown in the Results grid by their difference type, the following checkboxes can be used:
-
The Difference filter is used to affect what’s considered different within results since objects differ based on several attributes (i.e. two objects can be the same except for their owners):
In the following example, DDL trigger in source and destination differ only in extended properties, but that doesn’t need to be taken into consideration as a real difference, so it can be excluded:
To exclude extended properties for DDL trigger, locate it in the Difference filter panel, uncheck them, and it will be instantly applied on the Results grid. In this case, since the only difference was in the extended properties, the DDL trigger won’t be shown in the Results grid:
- The Result grid column filters can be accessed with a right-click on any column name:
To learn more about the Results grid’s filters, check out the following articles:
FAQs
Q: What will happen if I exclude a dependent object?
A: It depends on when an object was excluded. If an object was excluded:
- Before the database schema comparison process (in the Object filter tab) – dependent object won’t be picked up in the Dependencies step of the Synchronization wizard and it may cause failure in the synchronization process
- After the comparison process (in the Results grid) – the dependent object will be picked up in the Dependencies step of the Synchronization wizard if the Include dependent objects option is checked
Q: Can I save object filtering and reuse it later?
A: Yes. If any object filtering is set, it can be saved by saving the project file. Also, object filtering can be applied when using a project file in the CLI
Q: Can I set the same filter criteria for all object types in the Object filter panel vs. setting it up for each object type?
A: Yes. For example, if you want to set filter criteria to show all object types with database schema name Person, select the All objects in the Object filter panel, click the Filter button next to it, and enter the filter criteria to And schema name equals Person:
1 This is applicable only for ApexSQL Diff
2 ApexSQL Diff for MySQL Schema filtering in the Filter editor is not applicable
3 Group by is only applicable in the ApexSQL Diff