How to view the original script that built a materialized view and that was created by another user

materialized-vieworaclepermissions

In the Oracle database server use, another user (called MIMIC2DEVEL) created a materialized view and made it public. How to view the original script that was used to built it?

Here are the grants on the materialized view:

enter image description here

I am aware of How to view the original script of a materialized view? but the two solutions proposed there do not seem to work for materialized views that was created by another user.

I use Oracle SQL Developer and the database server runs:

enter image description here

Best Answer

Specify the owner in GET_DDL, or use ALL_MVIEWS instead of USER_MVIEWS:

select dbms_metadata.get_ddl('MATERIALIZED_VIEW', 'MVIEW_NAME', 'OWNER') from dual;

select query from all_mviews
  where mview_name = 'your materialized view';