Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view the original script of a materialized view?

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!

like image 856
AYR Avatar asked Jun 24 '13 06:06

AYR


People also ask

Can you query a materialized view?

You can use a materialized view in any SQL query by referencing the materialized view name as the data source, like a table or standard view. When a query accesses a materialized view, it sees only the data that is stored in the materialized view as of its most recent refresh.

How do I view materialized view logs?

A materialized view log is located in the master database in the same schema as the master table. A master table can have only one materialized view log defined on it. Oracle Database can use this materialized view log to perform fast refreshes for all fast-refreshable materialized views based on the master table.


2 Answers

You can use the function dbms_metadata.get_ddl:

select dbms_metadata.get_ddl('MATERIALIZED_VIEW', 'MVIEW_NAME') from dual;
like image 142
Marco Baldelli Avatar answered Sep 30 '22 04:09

Marco Baldelli


I ended up running:

select * from all_mviews where mview_name = ‘YOUR_MV_NAME’;
like image 38
manyways Avatar answered Sep 30 '22 03:09

manyways