How to view the original script of a materialized view?

AYR picture AYR · Jun 24, 2013 · Viewed 69.2k times · Source

I am interested in moving a materialized view from one db to the other, regardless, I also need to change one of the columns. How can I view the original script that build the MV? I am running TOAD, but cannot seem to find the original script.

Thanks in advance!

Answer

Marco Baldelli picture Marco Baldelli · Jun 24, 2013

You can use the function dbms_metadata.get_ddl:

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