The DBMS_METADATA_DIFF
package contains the interfaces for comparing two metadata documents in SXML format.
See Also:
Oracle Database Utilities for more information and for examples of using the Metadata APIThis chapter contains the following topics:
This section contains topics which relate to using the DBMS_METADATA_DIFF
package.
You can use the interfaces contained in the DBMS_METADATA_DIFF
package to compare two metadata documents in SXML format. The result of the comparison is an SXML difference document. This document can be converted to other formats using the DBMS_METADATA
submit interface and the CONVERT
API.
The browsing interface of the DBMS_METADATA_DIFF
package actually uses the DBMS_METADATA
package to fetch the metadata to be compared. Therefore, the security model used for DBMS_METADATA
also applies to DBMS_METADATA_DIFF
. (Note, however, that DBMS_METADATA_DIFF
does not support all object types.)
See Also:
DBMS_METADATA for information about the DBMS_METADATA security modelThese functions allow you to compare the metadata for two objects with a single call.
DBMS_METADATA_DIFF.COMPARE_SXML( object_type IN VARCHAR2, name1 IN VARCHAR2, name2 IN VARCHAR2, schema1 IN VARCHAR2 DEFAULT NULL, schema2 IN VARCHAR2 DEFAULT NULL, network_link1 IN VARCHAR2 DEFAULT NULL, network_link2 IN VARCHAR2 DEFAULT NULL) RETURN CLOB; DBMS_METADATA_DIFF.COMPARE_ALTER( object_type IN VARCHAR2, name1 IN VARCHAR2, name2 IN VARCHAR2, schema1 IN VARCHAR2 DEFAULT NULL, schema2 IN VARCHAR2 DEFAULT NULL, network_link1 IN VARCHAR2 DEFAULT NULL, network_link2 IN VARCHAR2 DEFAULT NULL) RETURN CLOB; DBMS_METADATA_DIFF.COMPARE_ALTER_XML( object_type IN VARCHAR2, name1 IN VARCHAR2, name2 IN VARCHAR2, schema1 IN VARCHAR2 DEFAULT NULL, schema2 IN VARCHAR2 DEFAULT NULL, network_link1 IN VARCHAR2 DEFAULT NULL, network_link2 IN VARCHAR2 DEFAULT NULL) RETURN CLOB;
Table 95-1 COMPARE_xxx Function Parameters
Parameters | Description |
---|---|
|
The type of object to be compared. Valid type names are |
|
The name of the first object in the comparison. |
|
The name of the second object in the comparison. |
|
The schema of the first object in the comparison. The default is the current user. |
|
The schema of the second object in the comparison. The default is the value of |
|
The name of a database link to the database on which the first object resides. If NULL (the default), then the object is assumed to be in the database on which the caller is running. |
|
The name of a database link to the database on which the second object resides. The default is the value of |
INVALID_ARGVAL
A NULL
or invalid value was supplied for an input parameter. The error message text identifies the parameter.
OBJECT_NOT_FOUND
The specified object was not found in the database.
These functions encapsulate calls to both DBMS_METADATA
and DBMS_METADATA_DIFF
functions and procedures to fetch the metadata for each of the two objects and compare them.
Which function you use depends on the comparison format you want:
COMPARE_SXML
returns an SXML difference document.
COMPARE_ALTER
returns a set of ALTER
statements for making the first object like the second object.
COMPARE_ALTER_XML
returns an ALTER_XML
document.
The DBMS_METADATA_DIFF
subprograms are used to:
Specify the type of objects to be compared
Specify the SXML documents to be compared
Show the differences between the compared documents
Clean up after the comparison
Table 95-2 provides a summary of DBMS_METADATA_DIFF
subprograms.
Table 95-2 DBMS_METADATA_DIFF Package Subprograms
Subprogram | Description |
---|---|
Specifies the type of objects to be compared |
|
Specifies an SXML document to be compared |
|
Returns a CLOB showing the differences between the two documents specified by |
|
Invalidates the handle returned by |
This function specifies the type of objects to be compared. The return value is an opaque context handle.
Table 95-3 OPENC Function Parameters
Parameters | Description |
---|---|
|
The type of object to be compared. Valid type names are |
The opaque handle that is returned is used as input to ADD_DOCUMENT
, FETCH_xxx
and CLOSE
.
This procedure specifies an SXML document that is to be compared.
DBMS_METADATA_DIFF.ADD_DOCUMENT( handle IN NUMBER, document IN sys.XMLType); DBMS_METADATA_DIFF.ADD_DOCUMENT( handle IN NUMBER, document IN CLOB);
Because the comparison interface allows you to compare exactly two SXML documents, a program must call ADD_DOCUMENT
exactly twice for each OPENC
handle. In the comparison result, the document specified by the first call is document 1, and the document specified by the second call is document 2.
The FETCH_CLOB
functions and procedures return a CLOB showing the differences between the two documents specified by ADD_DOCUMENT
.
DBMS_METADATA_DIFF.FETCH_CLOB( handle IN NUMBER) RETURN CLOB; DBMS_METADATA_DIFF.FETCH_CLOB(
handle IN NUMBER, doc IN OUT NOCOPY CLOB); DBMS_METADATA_DIFF.FETCH_CLOB( handle IN NUMBER, doc IN OUT NOCOPY CLOB diffs OUT BOOLEAN);