Using the following SQL, the DDL for a given materialized view can be obtained.
BEGIN
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM, 'STORAGE', FALSE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM, 'TABLESPACE', FALSE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', FALSE);
END;
SELECT DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW', 'OBJECT_NAME', 'SCHEMA_NAME') FROM DUAL;
I am having difficulty retrieving the DDL without the tablespace information. The SET_TRANSFORM_PARAM directives are actually documented as being specific to tables and indexes (not materialized views). The STORAGE one does actually work whereas the TABLESPACE and SEGMENT_ATTRIBUTES ones have no effect. Is there any way to omit the tablespace info from the generated DDL?
You need to set the object_type in the calls to SET_TRANSFORM_PARAM to MATERIALIZED_VIEW. In my example below, the tablespace is no mentioned: