20

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!

asteri
  • 11,402
  • 13
  • 60
  • 84
AYR
  • 1,139
  • 3
  • 14
  • 24

4 Answers4

30

You can use the function dbms_metadata.get_ddl:

select dbms_metadata.get_ddl('MATERIALIZED_VIEW', 'MVIEW_NAME') from dual;
Marco Baldelli
  • 3,638
  • 1
  • 22
  • 29
  • 9
    Use `dbms_metadata.get_ddl('MATERIALIZED_VIEW', 'VIEW', 'SCHEMA')` if you need to specify a different schema. – Ben Page Jul 17 '15 at 09:50
9

I ended up running:

select * from all_mviews where mview_name = ‘YOUR_MV_NAME’;
manyways
  • 4,386
  • 2
  • 23
  • 19
7
select query from user_mviews
  where mview_name = 'your materialized view';
Petr Pribyl
  • 3,425
  • 1
  • 20
  • 22
6

If you use Oracle SQL Developer you just have to go to the "view" or "materialized view" node of the navigation tree

Icaro
  • 2,527
  • 1
  • 15
  • 9