D.5 Handling Dependent Objects

For the JSON-type data that replaces your original, textual JSON data, you need to re-create any database objects that depend on that original data.

In general, you need to re-create all of the following, similar to what was defined for the textual data: indexes, materialized views, virtual columns (and any indexes on them), virtual private database policies, and triggers.

However, defining virtual columns and indexes is part of using online redefinition to migrate the data — it needs to be done on the interim table. See Using Online Redefinition to Migrate to JSON Data Type.

To find out which database objects depend on your original (textual) data, you can query the relevant static dictionary views, for example: USER_INDEXES, USER_TRIGGERS, and USER_VIEWS. You can then use PL/SQL function DBMS_METADATA.get_ddl to obtain the DDL code that was used to re-create such objects. Example D-5 shows how to do this for an index.

Typically, when the base objects underlying a materialized view are modified you need to recompile the materialized view. If that's not possible, then you need to re-create it.

To check whether a materialized view needs to be recompiled, you can query static dictionary view USER_MVIEWS, as follows:

SELECT MVIEW_NAME, COMPILE_STATE FROM USER_MVIEWS;

If the COMPILE_STATE value is NEEDS_COMPILE then you can recompile the view using ALTER MATERIALIZED VIEWCOMPILE.

Example D-5 Obtaining Information Needed To Re-Create an Index

This example first queries static dictionary view USER_INDEXES to find any indexes on textual JSON data in table j_purchaseorder.

SELECT INDEX_NAME FROM USER_INDEXES
  WHERE TABLE_NAME = 'J_PURCHASEORDER';

Supposing that the query result shows such an index named po_num_idx1, you can use DBMS_METADATA.get_ddl to obtain the DDL code that was used to create that index. You can then use similar DDL to create such an index on the equivalent data that you are migrating to JSON data type.

SELECT DBMS_METADATA.get_ddl('INDEX', po_num_idx1) FROM DUAL;

See Also: