DBMS_METADATA. GET_DDL / materialized view
I can use something like "select dbms_metadata.get_ddl (< object_Type >, < object_Name >) of double" to get the ddl for tables, views, etc. ; However, this doesn't seem to work for me now for the 11.1.0.7.0 version. What should I do to recover the ddl of a materialized view?Œuvres:
SELECT dbms_metadata.get_ddl('MATERIALIZED_VIEW', 'V_CUSTOMER')
FROM dual;
Does not work:
SELECT dbms_metadata.get_ddl('MATERIALIZED VIEW', 'V_CUSTOMER')
FROM dual;
Even for the other types-word-2: "PACKAGE_BODY" is correct, and "BODY of PACKAGE" is not correct.
Edited by: CharlesRoos May 21, 2010 05:16
Tags: Database
Similar Questions
-
I try to get the DDL for all materialized views in the database.
I am using under sql, but somehow, it does not understand it and gives me errors as follows:
SELECT DBMS_METADATA. GET_DDL ('MATERIALIZED VIEW', 'MV_NAME'), FROM DBA_OBJECTS;
or
SELECT dbms_metadata.get_ddl (OBJECT_TYPE, OBJECT_NAME, OWNER) IN DBA_OBJECTS
WHERE
OBJECT_TYPE AS "MATERIALIZED VIEW.
Gives me error like below:
ERROR:
ORA-31600: entry invalid value MATERIALIZED VIEW for the OBJECT_TYPE parameter in GET_DDL function
ORA-06512: at "SYS." Dbms_metadata", line 2682
ORA-06512: at "SYS." Dbms_metadata", line 2733
ORA-06512: at "SYS." Dbms_metadata", line 4333
ORA-06512: at line 1
Is there anyway I can get DDL for all the materialized view... ?
Anyhelp is appreciated.
JPHi, the valid object types do not have spaces, according to [this table | http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10577/d_metada.htm#BGBIEDIA].
Try this:
SELECT owner, object_name, object_type, dbms_metadata.get_ddl(replace(OBJECT_TYPE, ' ', '_'), OBJECT_NAME,OWNER) FROM DBA_OBJECTS WHERE OBJECT_TYPE = 'MATERIALIZED VIEW'
I didn't really take a broad look to check on each type of object, but this should work for at least materialized views. If this does work for other specific types you want, you may need to use decode or an expression box.
-
Parameter DBMS_METADATA. GET_DDL out of materialized views
Hi all.
My version of Oracle's 10g.
I am extracting DDL for all database objects using the DBMS_METADATA package. I use SET_TRANSFORM_PARAM to configure the output because I need a sql code simple, without information about the attributes of storage spaces, storage and segment. Everything works well except when I work with mviews object types. I can't remove the information about the attributes of the tablespace, storage or segment for materialized views.
I would like to know if there is a problem related to this topic. Or there is something missing in my code?
I tried to specify the type of object such as another parameter on DBMS_METADATA. SET_TRANSFORM_PARAM but not work too.
The only parameter transform that works very well with materialized views is the SQLTERMINATOR.
------
See how I did:
declare
CLOB vDDL;
Start
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);
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA. SESSION_TRANSFORM 'SQLTERMINATOR', TRUE);
Select dbms_metadata.get_ddl ('MATERIALIZED_VIEW', 'MV_STO020', 'HIS117_CHECK') in vDDL FROM DUAL;
dbms_output.put_line (vDDL);
end;
-------
and how the output is:
CREATE A MATERIALIZED VIEW 'HIS117_CHECK '. "" MV_STO020 ".
PCTFREE 10 BUNCH OF ORGANIZATION PCTUSED 40 INITRANS MAXTRANS 255 NOCOMPRESS LOGGING 1
STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
TABLESPACE "TS_HIS117".
IMMEDIATE CONSTRUCTION
USING INDEX
REFRESH THE STRENGTH TO DEMAND
WITH A KEY PRIMARY WITH THE HELP OF DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE THE QUERY REWRITING
IN SELECT
STO020_MOVEMENT_LOG_ID STO020_MOVEMENT_LOG_ID
STO020_QUANTITY STO020_QUANTITY
STO020_DATE STO020_DATE
STO020_BEFORE_BALANCE STO020_BEFORE_BALANCE
STO011_PRODUCT_MOVEMENT_ID STO011_PRODUCT_MOVEMENT_ID
ADM082_PRODUCT_ID ADM082_PRODUCT_ID
ADM089_PRODUCT_PRESENTATION_ID ADM089_PRODUCT_PRESENTATION_ID
STO010_MOVEMENT_TYPE_ID STO010_MOVEMENT_TYPE_ID
STO001_STOCK_ID STO001_STOCK_ID
STO001_TARGET_STOCK_ID STO001_TARGET_STOCK_ID
STO003_PRODUCT_LOT_ID STO003_PRODUCT_LOT_ID
SYS010_USER_ID SYS010_USER_ID
EIR001_MPI EIR001_MPI
ADM056_MEDICAL_ATTENTION_ID ADM056_MEDICAL_ATTENTION_ID
ADM094_USE_UNIT_ID ADM094_USE_UNIT_ID
Of
STO020_MOVEMENT_LOG;
Thank you in advance!
Published by: lucporto on 08/28/2012 07:26The LONG data type conversion is explained on http://asktom.oracle.com if you use the search feature.
I could not find real pointers to your original question it. -
Moving all the newspapers and Materialized View at the schema level using the data pump in
Hi Experts,
Please help me on how I can exp/imp all materialized views andMV logs (as are some MVs) only the full scheme of other databases. I want to exclude everything else.
Concerning
-Samar-Using DBMS_METADATA. Create the following SQL script:
SET FEEDBACK OFF SET SERVEROUTPUT ON FORMAT WORD_WRAPPED SET TERMOUT OFF SPOOL C:\TEMP\MVIEW.SQL DECLARE CURSOR V_MLOG_CUR IS SELECT DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW_LOG',LOG_TABLE) DDL FROM USER_MVIEW_LOGS; CURSOR V_MVIEW_CUR IS SELECT DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW',MVIEW_NAME) DDL FROM USER_MVIEWS; BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE); FOR V_REC IN V_MLOG_CUR LOOP DBMS_OUTPUT.PUT_LINE(V_REC.DDL); END LOOP; FOR V_REC IN V_MVIEW_CUR LOOP DBMS_OUTPUT.PUT_LINE(V_REC.DDL); END LOOP; END; / SPOOL OFF
In my case the script is saved as C:\TEMP\MVIEW_GEN. SQL. Now I will create a journal mview and mview in schema SCOTT and run the script above:
SQL> CREATE MATERIALIZED VIEW LOG ON EMP 2 / Materialized view log created. SQL> CREATE MATERIALIZED VIEW EMP_MV 2 AS SELECT * FROM EMP 3 / Materialized view created. SQL> @C:\TEMP\MVIEW_GEN SQL>
Run the C:\TEMP\MVIEW_GEN script. SQL generated a C:\TEMP\MVIEW queue. SQL:
CREATE MATERIALIZED VIEW LOG ON "SCOTT"."EMP" PCTFREE 10 PCTUSED 30 INITRANS 1 MAXTRANS 255 LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" WITH PRIMARY KEY EXCLUDING NEW VALUES; CREATE MATERIALIZED VIEW "SCOTT"."EMP_MV" ("EMPNO", "ENAME", "JOB", "MGR", "HIREDATE", "SAL", "COMM", "DEPTNO") ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" BUILD IMMEDIATE USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" REFRESH FORCE ON DEMAND WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT USING ENFORCED CONSTRAINTS DISABLE QUERY REWRITE AS SELECT "EMP"."EMPNO" "EMPNO","EMP"."ENAME" "ENAME","EMP"."JOB" "JOB","EMP"."MGR" "MGR","EMP"."HIREDATE" "HIREDATE","EMP"."SAL" "SAL","EMP"."COMM" "COMM","EMP"."DEPTNO" "DEPTNO" FROM "EMP" "EMP";
Now, you can run this on the database. You may need to adjust the tablespace and storage clauses. Or you can add more DBMS_METADATA. SET_TRANSFORM_PARAM calls to C:\TEMP\MVIEW_GEN. SQL to force DBMS_METADATA not to include the tablespace or / and the terms of storage.
SY.
-
How to get the text of the materialized view?
Hello
How to get test (query) of materialized view?
Thank youWith
the value of 10000 long
set pages 0
DBMS_METADATA. GET_DDL ('MATERIALIZED_VIEW', 'MV_EMP', 'SCOTT');Of course replace view_name and owner.
-
Hi all
I want to check the script or the DDlL of Materialized view.
whts the statement? Help, please.
Thanks in advance.Only.ashish99 wrote:
People here are only to acquire knowledge, I think. don't want spread.
56 people checked this request, but do not want to answer because there seems to be little.but it's an important thing for a beginner, we could get.
I understand the 56 people checked this query. But have you tried what I posted? If Yes, what was the error? If not or do not want to try why ask this question?
Second thing, you can be newbie but does google or the document does not have you helped with what means ORA-00904 means.Let me try if I can make you understand or not.
ORA-00904 means identifier valid, in other words, you used the object name is not valid or is not recognized by the current session of the Oracle.
This means that the object do not exist or you don't have privilege on this object.Do
desc dbms_metadata if above does not work grant execute on dbms_metadata to
--This should be done with sys login Concerning
-
ORA-12028: type of materialized view is not supported by the main site
Hi guys!
We face a problem these days about the materialized view.
We have upgraded database version 9.2.0.7 directly to 10.2.0.5 (RHEL4 x 86) on the same host. Database uses the driver dg4odbc to connect with remote SQL Server 2012 through data binding called MIKSERI. Our developer team would like to have replicated SQL server table data side Oracle using the materialized view.
They created Materialized view, but it is not at all to refresh the data. I tried to study a little bit, and whenever I try to change the view anyway I hit error:
ORA-12028: view type is not supported by the master site materialized @ 'MIKSERI '.
ORA-06512: at line 22
I looked at the solutions proposed and discovered that it is maybe the compatible database parameter, so I changed from previous 9.2.0.0.0 to 10.2.0.1.0 but still no luck. Just to emphasize this database is of course different clone of production to a different database, with db name retained and other parameters, but on another host computer and listening port. I even try to change global name, but still no luck.
Main problem is that refresh the work does not at all. To be more precise, we have created MV on the side of the Oracle and FULL Refresh should be done every 3 minutes. MV uses HS db link to the sql server database.During the creation of MV, we can see currently given to sql server, but the problem is that we cannot do MV to refresh every 3 minutes. When I try to change MV and put the refresh interval I get above error.
Any kind of help would be greatly appreciated,
Thank you
I found the reason why my MV update jobs failed, job_queue_processes parameter was equal to 0. I change this setting and now works fine.
Thank you for your time!
-
What is the best way to change a column type in the materialized view?
Hello my dear friends,.
I want to change a column type in a materialized view. VARCHAR2 NUMBER, so what do you recommend? What is the best way to do it?
Thank you
You can not change the data type of the column while there are data in the MV, so you might as well give up and recreate the MV with a TO_CHAR() around the column in question in the application of MV to get the data exactly as you want (be sure to include an appropriate format mask). That said, I'm fighting to think reasonable grounds to make such a change.
-
A drop materialized view error
I tried to drop two materialized views (I want to drop one and the other as a test to make sure that the behavior was consistent) with SQL Developer today, using the GUI, not the window of SQL command. When I did this, Developer SQL with these MVs among the tables, he tried to run a 'DROP TABLE' rather than a 'DROP MATERIALIZED VIEW' statement and an ugly error message came up with that and of course she didn't. Is this a bug that needs to be addressed? Or maybe that it is already identified and addressed in a future version?
Earl
Looks like you're down the underlying table, not the materialized view. If you have a my_mv of materialized view, there is also a table called my_mv.
You must drop the materialized since the Materialized View node in Object Explorer view.
-
Materialized views Refresh method and refresh option
Hi Experts,
According to the docs, If the MV contains the following, MV is considered complex. I wonder is there any view data dictionary that indicates the type of MV? Because is very easy to the candidate a complex type mv. Because many queries contains the properties below.
http://docs.Oracle.com/CD/B28359_01/server.111/b28326/repmview.htm#i52501
http://docs.Oracle.com/CD/B28359_01/server.111/b28313/basicmv.htm
Specifically, a materialized view is considered complex if the materialized view definition query contains:
- A
CONNECT
BY
clause - An
INTERSECT
,MINUS
, orUNION
ALL
operation - he
DISTINCT
orUNIQUE
keyword - In some cases, an aggregate function, although it is possible to have an aggregation function in the query definition and always have a simple materialized view
- In some cases, joins other than those in a subquery, although it is possible to have joins in the definition to interrogate and still have a simple materialized view
- In some cases, a
UNION
operation
After that I kept going to read that I learned that when a VM is created, the refresh mode is specified according to the type of the MV. That means, using ON-DEMAND refresh mode is widespread. The documentation mentions that there isa also refresh option. My question is, is it possible to specify
ON REQUEST and FAST together?
Also, what are the differences between FULL and FAST. Ends truncate the table and fill it up again?
Refresh product automatically when a transaction which changed one of the paintings of the materialized view's retail is committed. This can be specified as the materialized view is quickly updatable (in other words, not complex). The
ON
COMMIT
privilege is required to use this mode.Refresh occurs when a user manually executes one of the procedures available refresh contained in the
DBMS_MVIEW
package (REFRESH
,REFRESH_ALL_MVIEWS
,REFRESH_DEPENDENT
).Refreshes and recalculating the materialized view query definition.
Applies incremental changes to refresh the materialized view using the information recorded in the papers of the materialized view, or an SQL * Loader direct-path access or a partition maintenance operation.
Applies
FAST
update if possible; otherwise, it appliesCOMPLETE
Refresh.Indicates that the materialized view will not be updated with updating mechanisms.
Select * from version of v$.
Oracle Database 11 g Release 11.2.0.4.0 - 64 bit Production
Thank you
Çaglar wrote:
...
Also, what are the differences between FULL and FAST. Ends truncate the table and fill it up again?
...
Thank you
I just want to answer the truncated question. Seems that nobody covered that yet.
Answer: It depends.
If you do a full refresh, then the default is to use ATOMIC_REFRESH = TRUE.
This means that the update is done via an insert, delete , and ... Select.
You can change it to ATOMIC_REFRESH = FALSE (parameter dbms_mview.refresh).
This means that is a TRUNCATE and insert a ... Select with APPEND peak (path direct insert).
Refresh if Atomic = FALSE is considerably faster than the default. Also way less Archives of newspapers are written.
The downside is however that, during the update the MV is empty, is no longer an atomar operation!
See also Oracle documentation: http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_mview.htm#i997194
- A
-
What is 'Table of container' in materialized views
Hello
What is meant by ' Container Table ' in materialized views?
"Materialized view" (MV) is, in fact, a table, rather than a view.
The term MV is used of the 9i database. In the 7 and 8 databases is the term 'snapshot' (to make things more complicated, the MV concept appeared in the 8i database, but in the context of the data warehouse).
When you create a MV, for example. using the:
Create materialized view emp_mv
full refresh on demand
as select empno, ename from EMP
/
you have, in fact, have created two objects in the data dictionary:
Select object_name, object_type
from user_objects
where object_name = 'EMP_MV. '
order by 1, 2;
OBJECT_NAME OBJECT_TYPE
--------------------- -------------------
MATERIALIZED VIEW EMP_MV
EMP_MV TABLE
You can remove MV and a table of container:
drop materialized view emp_mv;
or you can delete only MV, preserving a table containing:
Let fall the materialized view emp_mv maintain the table;
Kind regards
Zlatko
-
What is materialized views named?
Hi there;
When I read the documentation below, I met a sentence.
http://docs.Oracle.com/database/121/DWHSG/basicmv.htm#i1007299
Materialized views with subqueries or views named in the DE clause can be fast refreshed as points of view can be completely merged.
What is the point of view named? Thanks in advance.
Hello
Named views are normal views created by running ' create view abc as select... from...» ».
Kind regards
Bashar
-
MATERIALIZED View Log Index Tablespace
Is anyone aware of the syntax or a framework to be able to specify the index of a materialized view of the journal storage space?
We chunk our objects by tablespace - index, tables, CLOB.
Creating a materialized view log and specifying the storage space in which it should be created created the mv log in the correct location, but the index that is created uses the default tablespace for the user.
And Yes, I Googled it. LMGTFY
create materialized view log on MY_TEST tablespace my_tablespace ;
select table_name, tablespace_name from user_tables where table_name like 'MLOG%';
TABLE-NAME TABLESPACE_NAME MLOG$ _MY_TEST MY_TABLESPACE select table_name, index_name, tablespace_name from user_indexes where table_name like 'MLOG%';
TABLE-NAME INDEX_NAME TABLESPACE_NAME MLOG$ _MY_TEST I_MLOG$ _MY_TEST USERS I found these documents:
Index on MLOG$ (materialized view Log): difference in behavior between 11.2.0.3 and 11.2.0.4 (Doc ID 1959657.1)
Materialized View Log (Mlog$) Index not created in its default Tablespace (Doc ID 1959658.1)
I guess you are running 11.2.0.4, right?
In previous versions, no index has been created automatically for the journal of MV.
Kind regards
Bashar
-
strange dbms_metadata.get_ddl TS DDL
11.2.0.2 Oracle 64-bit
Oracle Linux 5
In another issue (isn't that where we find always the uh, interesting things?) I came across something odd about a definition of TS returned by dbms_metadata. Launched a couple of other requests for related information together. Note that the supposed definition of the ts includes an alteration of a redo log file.
Sign me - stumped.
SQL > SELECT DBMS_METADATA. GET_DDL ('TABLESPACE', 'PSUNDOTS') of double;
DBMS_METADATA. GET_DDL ('TABLESPACE', 'PSUNDOTS')
--------------------------------------------------------------------------------
CREATE UNDO TABLESPACE "PSUNDOTS" DATA FILE
' / u01/oradata/fs91dmo/psundots01.dbf' 314572800 SIZE
AUTOEXTEND ON NEXT 5242880 MAXSIZE 32767M.,
' / u01/oradata/fs91dmo/redo03.log' 314572800 SIZE
AUTOEXTEND ON NEXT 5242880 MAXSIZE 32767M
BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
ALTER DATABASE DATAFILE
' / u01/oradata/fs91dmo/psundots01.dbf' 3145728000 RESIZE
ALTER DATABASE DATAFILE
' / u01/oradata/fs91dmo/redo03.log' 3145728000 RESIZE
1 selected line.
SQL > select file_name
2 of dba_data_files
3 where nom_tablespace = 'PSUNDOTS ';
FILE_NAME
---------------------------------------------
/U01/oradata/fs91dmo/psundots01.dbf
1 selected line.
SQL > select group #,.
2 Member
3 v $ logfile
4 order of 1,2;
GROUP # MEMBERS
---------- ---------------------------------------------
1 /u01/oradata/fs91dmo/redo01.log
2 /u01/oradata/fs91dmo/redo02.log
3 /u01/oradata/fs91dmo/redo03.log
3 selected lines.
SQL >--
SQL > spo off
Hello
It is clearly a bug:
Bug 10177856 - DBMS_METADATA.get_ddl ('tablespace',...) includes wrongly tempfiles and redo-log online (Doc ID 10177856.8)
Kind regards
Bashar
-
What is a materialized view?
If I read oradocs on flashback instructions table and it mentions
When you delete a table, all the newspapers view materialized, defined on the table are also deleted, but are not placed in the Recycle Bin. Therefore, the materialized view logs cannot be flashed back as well as the table
(http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9012.htm#SQLRF01802)
then I went to oradocs for the view materialized and read the first half logs.
http://docs.Oracle.com/CD/B19306_01/server.102/b14200/statements_6003.htm
Now, I know what makes a materialzed view log.
is a materialized view as a point of view however... ?
No, it isn't.
A materialized view is basically a query with its 'materialized' or stored in a table results. A MV can be used by Oracle in a manner transparent re - write a query to be faster.
Maybe you are looking for
-
HP Officejet 8625: Interference of your Fax with phone
I have a desktop with Mac laptop, desktop and HP Officejet 8625 phone. I have my Officejet connected to my 1 d phone jack, and when I get a phone call I have a fax on the line tone. How do I remove it?
-
Unable to connect Blackberry AppWorld on BlackBerry Smartphones
I can connect my legacy but to the 2nd floor when my PIN code and I submit error message so I cannot go further... How to solve it, please,
-
Need help to convert a config 881 in 1921
Here's a copy of my 881 easy vpn cisco config. Can you get it someone please let me know what I need to change to make it work on a cisco 1921. Thanks in advance hostname BTLvpn boot-start-markerboot system flash: c870-advipservicesk9 - mz.124 - 11
-
I can connect to my home network, but all the other networks do not work... Error window says: Windows could not connect to the (X)? network name? [Link] Solve problems [Link] Learn more about Internet connection problems I gave security, uninstalled
-
For some reason, my media files, or the song titles have been dupicating and adding the files on my computer. What I did and how it stop continue? Someone please Help!