Oracle(R) Enterprise Manager Getting Started with Oracle(R) Change Management Pack Release 2.1 A76919-01 |
|
The Plan Editor application allows you to modify or reproduce (or both) database object definitions at one or more databases.
With Plan Editor, you create or modify a single change plan and populate it with change requests. To deploy the plan, you specify one or more destination databases, generate a script to apply the plan's change requests at each database, then execute the scripts.
You can also create change plans with DB Diff's Synchronization wizard, DB Alter, DB Quick Change, and DB Propagate. However, these applications differ from Plan Editor because each of them is designed to create a change plan with specific types of change requests that make specific types of changes.
Plan Editor is a more flexible change plan tool. You can use Plan Editor to create and modify a change plan that includes any type of change request and to make a wider variety of changes.
This chapter explains in detail the steps for modifying and creating object definitions using Plan Editor.
This section describes how to start the Plan Editor application and use it to modify and create object definitions.
To create a new plan using Plan Editor, follow these steps:
After Plan Editor creates the empty plan, you need to define one or more change requests to add to the plan. Depending on what you want the plan to accomplish, you will define directives, exemplars, or both for the plan.
A directive is a set of changes you specify for an existing, named object definition. A directive can be thought of as a "Super Alter" statement.
A directive for an object definition tells an Oracle Change Management Pack application, "Make these specific changes to the object definition." Suppose, for example, that you are defining a directive for a table named Table_1. Some of the change requests that you could specify in a directive for table Table_1 include:
You create a directive for an object definition by selecting an object definition to be modified, then specifying the changes to the object definition's attributes on property sheets similar to those in DBA Studio.
A directive has the scope of a single object definition (the changes made by the directive are applied to a single object definition).
It is also possible to extend the scope of a directive so that the changes specified in the directive are applied to multiple object definitions that you specify. A directive with an extended scope is called a scoped directive. Use a scoped directive to make the same set of changes to more than one object definition.
Change plans created with the following applications contain only directives:
Change plans created with Plan Editor can contain directives, scoped directives, and exemplars (or any combination of these types of change requests).
An exemplar is a complete object definition to be reproduced, either by creating a new object definition or by modifying an existing object definition of the same name and object type. An exemplar can be thought of as the example of what you want to reproduce.
An exemplar tells an Oracle Change Management Pack application, "Reproduce this object definition. If an object definition of the same name and type already exists, make whatever changes are necessary to that object definition so that it matches this object definition. If the object definition does not exist, create an object definition that matches this object definition." When you define an exemplar, you can also include grants information for the exemplar.
Change plans created with the following applications contain only exemplars:
Change plans created with Plan Editor can contain exemplars, directives, and scoped directives (or any combination of these types of change requests).
Table 3-1 summarizes the types of change requests that can be created with Oracle Change Management Pack applications.
Some Oracle Change Management Pack applications (such as DB Alter and DB Propagate) make it evident when you are creating change requests because these applications prompt you to add directives or exemplars to the change plan. Other applications (such as DB Diff's Synchronization wizard and DB Quick Change) prompt you to select object definitions to copy or modify, but do not make it evident that the selected definitions are directives or exemplars that are being added to the change plan. DB Search does not create change requests.
To specify the modifications to be made to an existing object definition at the destination database, follow these steps to define a directive for that object definition in the source database:
Note that a directive describes the changes you want to make to an object definition. Therefore, the meaningful part of a directive is the changes that you have specified. You can view these changes by clicking the directive in the Plan Editor tree and viewing the list of changes on the General page for the object. After you have created a directive for an object, you can make further edits to the directive if the object still exists in the change plan's source database. When you make further edits to a directive, the object's definition is loaded from the source database, and the edits already specified in the directive are applied to the object.
By default, a directive contains the changes to be applied to a single object definition. However, it is possible to extend the scope of a directive so that the changes specified in the directive are applied to multiple object definitions that you specify. A directive with an extended scope is called a scoped directive.
Scoped directives can be very powerful. For example, suppose that you want to move several tables to a new tablespace without creating a separate directive for each table you want to move. Instead, you can create a directive for one of the tables, and in that directive specify the name of the new tablespace for the table. Then you can edit the scope specification for that directive, making sure that the search criteria identifies the other tables that you want to move to the new tablespace. When the script is generated, the scoped directive's instructions are applied to each object that matches the search criteria. When the script executes, it carries out the scoped directive's instructions on each matched object. In this example, all the tables that match the scope directive's search criteria are moved to the new tablespace that is specified in the scoped directive.
To create a scoped directive, follow these steps:
The Edit Directive Scope dialog box contains the following fields:
Displays the object type of the directive object. This field is non-editable.
If the directive object is a non-schema object, you cannot modify this field.
If the directive object is a schema object, you can modify this field. To include any schema name in the search criteria, click Any Schema. To include any schema name except the SYS and SYSTEM schemas, click Exclude SYS, SYSTEM after clicking Any Schema.
To include specified schemas or wild card patterns in the search criteria, click Add. The Select Schemas dialog box is displayed. Use the Select Schemas dialog box to add specified schemas or wild card patterns to the search criteria. If you specify wild card patterns, any schema name that matches the pattern will be included in the search criteria.
To remove specified schemas or wild card patterns from the search criteria, select the item in the Schemas list, then click Remove.
To include any object name in the search criteria, click Any Object Name.
To include specified object names or wild card patterns in the search criteria, click Specified Object Names and then click Add. The Select Names dialog box is displayed. Use the Select Names dialog box to add specified object names or wild card patterns to the search criteria. If you specify wild card patterns, any object name that matches the pattern will be included in the search criteria.
To remove specified schema names or wild card patterns from the search criteria, select the item in the Search For list, then click Remove.
Scoped directives are marked with both the scoped directive icon and an object type icon. The scoped directive icon appears first, followed by the object type icon, then the name of the object. The scoped directive icon is shown in Figure 3-3.
A change plan can have only one change request for an object in a destination database. For example, a plan cannot contain both a directive and a scoped directive for the same object in a destination database. If a change plan contains multiple change requests for the same object, this problem will be identified in the impact report.
Refer to the online help for more information on scoped directives.
To reproduce an existing object definition at a destination database, you create an exemplar for that object definition in the source database. Later, when the script generated from the change plan is executed against the destination database, one of the following three actions is performed for each exemplar in the change plan:
To reproduce an existing object definition at a destination database, follow these steps to create an exemplar for that object definition in the source database:
Select one or more of an exemplar's grants and click the Exclude button to exclude those grants from the plan. If you decide later that you want to include one or more excluded grants for an exemplar in the plan, select those grants, then click the Include button to include them in the plan.
After you include a specific grant for an exemplar in a plan, it is possible for the same grant to be modified in the database. In this case, the Refresh button becomes available when you select that grant on the Grants page. If you want to update the grant in the plan to match the grant in the database, select the grant, then click the Refresh button.
If no grants are associated with the exemplar, the Grants page does not display any grants.
The Dependencies page displays the objects that the exemplar depends on. Each dependency object definition on the Dependencies page should be added to the plan, except for those object definitions that already exist at the destination database. For example, suppose you add an exemplar for a trigger to a plan, and the trigger refers to a table that is not in the plan and which does not exist at the destination database. In this case, you should manually add an exemplar for the referenced table to the plan, otherwise the trigger cannot be created at the destination database. To manually add a dependent object to the plan, select the object definition and click Add to Plan. Objects that are already in the plan are unavailable.
The Dependents page displays the objects that depend on the exemplar. You can use this page to locate other object definitions that are related to the exemplar, and, if you wish, manually add them to the plan. To manually add a dependency object definition to the plan, select the object definition and click Add to Plan. Objects that are already in the plan are unavailable.
If your plan contains table exemplars, you can reproduce both the table definitions for the exemplars and the data associated with the table definitions at a destination database. To do so, select the Copy Table Data option. If you want to reproduce only the definitions for the table exemplars, do not select the Copy Table Data option.
See the online help for a complete list of the propagate options and a description of how their values affect the application of a change plan's exemplars at a destination database.
To select the destination database where you want the plan to be executed:
After a destination database has been selected, a script can be generated from the change plan. The script generated from the change plan (not the plan itself) will be run against the destination database. During the initial stage of script generation, Oracle Change Management Pack examines the structure and definitions in the destination database so that it can generate a script designed exclusively for execution against the destination database.
When you use a single plan to generate scripts for several databases that have different structures and definitions, Oracle Change Management Pack generates a different script for each database. This is because Oracle Change Management Pack takes each destination database's structure and definitions into account when generating the script.
For example, suppose your plan contains an exemplar for table Table_2, and you use Oracle Change Management Pack application to generate two scripts, one to run against destination database DB_1 and the other to run against destination database DB_2. If table Table_2 does not exist in database DB_1, the script generated for DB_1 will include statements that define table Table_2. If a different version of table Table_2 already exists in database DB_2, the script generated for DB_2 will include statements to make the definition of table Table_2 in database DB_2 match the exemplar for table Table_2.
After Oracle Change Management Pack generates a script for a destination database, you can view and, optionally, edit the script. Oracle Change Management Pack also creates an impact report when it generates the script. You should view the impact report to determine the impact of executing the script at the destination database. The impact report provides a summary of the number and types of objects that will be modified when the script executes at the destination database. The impact report also shows warnings and errors, including a description of the requested operations that cannot be performed at the destination database, for example, a request to drop a column that no longer exists at the destination database.
If you modify a plan's change requests after you have generated one or more scripts for the plan, Oracle Change Management Pack considers the scripts that have been generated to be obsolete scripts. When you try to execute an obsolete script, Oracle Change Management Pack displays a message that advises you that the plan was modified after the script was generated and confirms whether you want to execute the script anyway. It is prudent to generate a new script from the modified plan instead of executing an obsolete script.
To generate a script for the destination database:
You can also specify a scratch tablespace that Oracle Change Management Pack can use for script operations that require temporary storage of data. For example, renaming a tablespace requires a scratch tablespace because all the data in the tablespace must be stored temporarily while the first tablespace is dropped and recreated. Other operations, such as operations on a table, require either enough storage space in the table's tablespace for two copies of the original table or a scratch tablespace to contain the table copy.
Figure 3-5 shows a fully expanded change plan in Plan Editor with the Script subobject selected.
Oracle Change Management Pack creates an impact report when it generates the script. You should view the impact report to determine the impact of executing the script at the destination database. The impact report provides a summary of the number and types of objects that will be modified when the script executes at the destination database. The impact report also shows warnings and errors, including a description of the requested operations that cannot be performed at the destination database, for example, a request to drop a column that no longer exists at the destination database.
After generating the script, you should view the impact report and script summary. You can also edit the script.
Script errors must be fixed. Evaluate the errors, take corrective action, then regenerate the script.
Script warnings should be read and the appropriate action taken before you attempt to execute the script. Some warnings are informational, for example, a message that dropping a column will cause an index to be dropped, as shown in Figure 3-5. To save the impact report to a file, click the Save As button.
Note that scripts produced by Oracle Change Management Pack applications can only be run using Oracle Change Management Pack applications, the Oracle Change Management Pack command line interface, or the Oracle Enterprise Manager job system. See "execute command" for more information about executing a script using the command line interface. See the online help for more information about executing a script using the job system.
A script that has been edited can be executed even if it has script generation errors.
If the impact report or the script summary is unacceptable, you can take one or more of the following actions:
To ensure that you can undo the execution of a script, Oracle Change Management Pack makes a copy of the old data when needed for recovery purposes. The recovery data is stored in temporary tables that look like the original tables but have different names.
Oracle Change Management Pack allows you to keep or undo the changes made when a script is executed.
If you keep the changes, the temporary tables used by the recovery script are deleted, making the changes permanent.
If you undo the changes, the recovery script uses the recovery data to return the user tables and data to their original state.
To execute the script against the destination database:
If you want to execute the plan's change requests against a different destination database, select a new destination database, then generate, view, and execute a new script against the database.
You can also execute an Oracle Change Management Pack script using:
The two main causes of script execution errors are:
When the Oracle Change Management Pack translator generates a script for a destination database, it takes the current structure of the database into account. If objects at the destination database are deleted or modified after the script is generated, the script is considered to be a stale script. Errors can occur during the execution of a stale script or recovery script. For example, if a particular user is removed from a destination database before you run a script, the execution log may display an error message such as this after the statement that generated the error message:
ORA-01918: user `GEORGE' does not exist
To have Oracle Change Management Pack predict script execution failures (the default), enable the OCM_FAILURE_PREDICTION property in the ocm.properties file. The property is enabled when its value is set to "true" (case insensitive) or when the property does not exist in your ocm.properties file. When failure prediction is enabled, Oracle Change Management Pack performs resource checking (for example, it checks for sufficient space and quota to make copies of tables or to move items from one tablespace to another) during script generation. Resource warnings are reported in the impact report. Script generation takes longer when failure prediction is enabled.
If the property is present and has a value other than "true," then resource checking and script failure prediction does not occur.
When error messages occur during script execution, the best ways to fix the problem are:
When error messages occur during recovery script execution, the best ways to fix the problem (in order of preference) are: