Setting DBMS_METADATA.GET_DDL Output for Materialized Views
Hi all.
My Oracle version is 10g.
I'm extracting the DDL of all the objects from database using the DBMS_METADATA package. I'm using SET_TRANSFORM_PARAM to configure the output because I need a simple sql code, without information about tablespaces, storage and segment attributes. Everything works fine except when I'm working with mviews object types. I can't remove the information about tablespace, storage or segment attributes for materialized views.
I would like to know if there's a related issue about it. Or there's something missing in my code?
I tried to specify the object type as another parameter on DBMS_METADATA.SET_TRANSFORM_PARAM but don't work too.
The only transform parameter that works fine with Materialized Views is the SQLTERMINATOR.
See how I have done:
declare
vDDL clob;
begin
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') into vDDL FROM DUAL;
dbms_output.put_line (vDDL);
end;
and how the output is:
CREATE MATERIALIZED VIEW "HIS117_CHECK"."MV_STO020"
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)
TABLESPACE "TS_HIS117"
BUILD IMMEDIATE
USING INDEX
REFRESH FORCE ON DEMAND
WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS 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
FROM
STO020_MOVEMENT_LOG;
Thank you in advanced!
Edited by: lucporto on 28/08/2012 07:26
Right. I found this way but I consider this just a quick fix, because I think there should be a better way to do this.
create table t_clob (c_long);
declare
p clob;
begin
delete from t_clob;
execute immediate 'insert into t_clob (select to_lob(query) from dba_mviews where owner = :1 and mview_name = :2)'
USING 'HIS117', 'MV_STO020';
select 'CREATE MATERIALIZED VIEW MV_STO020' || chr(10) ||
'REFRESH ON DEMAND' || chr(10) || 'AS' || CHR(10) || mv.c_long
into p
from t_clob mv;
dbms_output.put_line(p);
end;
Thanks all.
Similar Messages
-
Dbms_metadata.get_ddl output format is not runable.
Hi,
I am using dbms_metadata.get_ddl to extract the objects. But the output returned is not runable.
In output lines are broken so it makes unable to run that code.
Ex. If I run this for all the synonyms like this.
set pagesize 0
set long 90000
set feedback off
set echo off
spool /tmp/FixSyn.out
select
DBMS_METADATA.GET_DDL('SYNONYM',u.object_name,'ADMINSRV_D1')
from
dba_objects u
where
object_type = 'SYNONYM' and owner= 'ADMINSRV_D1';
spool off;
Output from this is coming like this.
CREATE OR REPLACE SYNONYM "ADMINSRV_D1"."ASSTATEAPPORVALTYPE222" FOR "ADMINSRV
_D1"."ASSTATEAPPORVALTYPE";
CREATE OR REPLACE SYNONYM "ABC"."ASSTATEAPPORVALTYPE3" FOR "ADMINSRV_D
1"."ASSTATEAPPORVALTYPE";
This is broken in multiple lines so not possible to run this.
Please provide any solution to fix this output.
Thanks a lot,
Amit.How about using word_wrapped
set pagesize 0
set long 90000
set lines 131
column txt format a121 word_wrapped
set feedback off
set echo off
spool /tmp/FixSyn.out
select
DBMS_METADATA.GET_DDL('SYNONYM',u.object_name,'ADMINSRV_D1') txt
from
dba_objects u
where
object_type = 'SYNONYM' and owner= 'ADMINSRV_D1';
spool off;
For help on Column and default attributes.
SQL> help column
You can also check asktom replies.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:30802454515375
Regards,
Sabdar Syed. -
Refresh time for Materialized View
Hi,
I have created a materialized view and set it to refresh everyday at 4 am . When I check the status of the job , it shows the refresh timing between 20 mins to 4 hours . That means , some times it takes 20 mins to refresh , some times 40 , some time 2 hours and some times up to 4 hours. Any reason for the wide range ? Here is the query for the view.
CREATE MATERIALIZED VIEW BDS_COST_CATEGORY_MV
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)
TABLESPACE "USERS"
BUILD IMMEDIATE
USING INDEX
REFRESH COMPLETE ON DEMAND START WITH sysdate+0 NEXT ROUND(SYSDATE + 1) + 4/24
USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS SELECT AC.ACCOUNT_MANAGER, AC.ACCOUNT_NUMBER,
AC.ACCOUNT_NAME, DIV.DIVISION_NUMBER, ITEM.CODE_ID,
ITEM.CODE_NAME COST_CATEGORY_ITEM,
TO_NUMBER(TO_CHAR(AP.FIRST_DAY,'YYYY')) PERIOD_YEAR,
AP.FIRST_DAY PERIOD,
SUM(NVL(AD.CURRENT_EXPENSE,0)) EXPENSE
FROM ACCOUNTS AC, PERSONNEL AC_MGR, DIVISIONS DIV, ASR_HEADERS AH , ASR_DETAILS AD, CODES ITEM, CODES COSTCAT, ALL_PERIODS AP,
CODES COST_ELEMENT, ACCOUNTING_BASE_GROUP ABG
WHERE AC.ACCOUNT_MANAGER = AC_MGR.PERSONNEL_ID
AND AC_MGR.DIVISION_ID = DIV.DIVISION_ID (+)
AND AC.ACCOUNT_ID = AH.ACCOUNT_ID
AND AH.ASR_HEADER_ID = AD.ASR_HEADER_ID
AND AH.PERIOD_ASR = AP.FISCAL_SYSTEM_PERIOD_CAL_YR_EQ||', '|| AP.FISCAL_YEAR
AND ABG.COST_ELEMENT_CAT_ITEM_ID = ITEM.CODE_ID
AND COST_ELEMENT.CODE_ID = ABG.COST_ELEMENT_ID
AND AD.OBJECT_CODE = COST_ELEMENT.CODE_VALUE
AND ITEM.CODE_PARENT_ID = COSTCAT.CODE_ID
AND ( COSTCAT.CODE_NAME = 'BDS' OR ( COSTCAT.CODE_NAME = 'Base' AND ITEM.CODE_NAME = 'MTDC'))
GROUP BY AC.ACCOUNT_MANAGER,AC.ACCOUNT_NUMBER, AC.ACCOUNT_NAME,
DIV.DIVISION_NUMBER, ITEM.CODE_ID, ITEM.CODE_NAME,
TO_NUMBER(TO_CHAR(AP.FIRST_DAY,'YYYY')), AP.FIRST_DAYThis appears to be a duplicate of Refreshing Materilized view. I replied on the other thread.
Justin -
DBMS_METADATA.GET_DDL - output trucating
Hi,
I am generating Database Package Scripts using the following.
=====================================================
set pagesize 0
set long 90000
set feedback off;
column DDL format a80 WORD_WRAPPED
spool FMONTUSER_PACKAGE.sql
select dbms_metadata.get_ddl(object_type,object_name,owner) DDL from dba_objects
where owner='FMONTUSER' and
object_type in('PACKAGE');
spool off;
============================================
This is the last PROCEDURE of Last PAKCGE in FMONTUSER_PACKAGE.sql
=============================================
PROCEDURE insert_loan_year_end_data(argloan_id IN LOAN.LOAN_ID%TYPE,
arg_temp_prio_end_row IN TEMP_PRIOR_YEAR_END%ROWTYPE)
IS
v_as_of_dt LOAN_YEAR_END_DATA.ASOFDATE%TYPE;
BEGIN
-- Insert the record into original loan table
DBMS_OUTPUT.put_line ('before insert LOAN_YEAR_END_DATA');
v_as_of_dt := arg_temp_prio_end_row.AS_OF_DATE;
INSERT INTO LOAN_YEAR_END_DATA VALUES(LOAN_YEAR_END_DATA_SEQ.NEXTVAL,argloan_id,
arg_temp_
prio_end_row.BEGINNING_PRINCIPAL_BAL,arg_temp_prio_end_row.YTD_PRINCIPAL_PAID,
=============================================
I am getting trucated some lines in this procedure.
I increased 'set long 90000' to 'set long 100000'
Still I am getting truncated output.
Please help me to solve this.
regards,
MathewHi,
This script I am using.
=======================================
set pagesize 0
--set long 90000
set long 2000000000
set feedback off;
column DDL format a80 WORD_WRAPPED
EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'PRETTY',true);
EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS',true);
EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'REF_CONSTRAINTS',false);
EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS_AS_ALTER', false);
EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'STORAGE', false );
EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', false );
EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'TABLESPACE', false );
spool FMONTUSER_PACKAGE.sql
REM -------------------------------------------------------------------------------------------------------
REM FMONTUSER_PACKAGE.sql
REM PACKAGE.sql
select dbms_metadata.get_ddl(object_type,object_name,owner) DDL from dba_objects
where owner='FMONTUSER' and
object_type in('PACKAGE');
spool off;
regards
Mathew -
Refresh FAST for Materialized View failed after Partition Operation
Dear all,
I have created a Materialized View having a simple join between a Dimension and Fact Table of a Datawarehouse. The MV is REFRESH FAST ON DEMAND.
However, when a Partition Maintenance Operation (PMOP) was performed on the Master Tables, the MV failed to Refresh giving a ORA-32313 error.
As suggested on one of the troubleshooting websites, we did a complete refresh of the MV and fixed it temporarily. However, I would like to know the exact cause for this and would like to have a permanent fix for the same.
Can the DBA for this Database provide me the answers or are there some standard troubleshooting steps for the same?
Please let me know.
Best,
KetanHello Maurice,
Here are the answers to your questions.
1) Database is Oracle 9i.
2) We have a stored procedure to refresh the MV. The command is dbms_mview.refresh('SALES_FACT_MV','f'). It was working fine daily. Only after a PMOP was done on the Master Tables, it failed to refresh. We have also created indexes on some columns of the MV for performance improvement. We are getting a very good improvement.
3) We have MV logs for both Master Tables to store the incremental values.
4) We are not able to get the output from DBMS_MVIEW.EXPLAIN_MVIEW since this can be done only by the DBA. WIll update you once I have the info.
5) Same as Point 2.
Let me know if you need any further info.
Thanks, Ketan -
Help needed in query for Materialized View
Hi,
I want to create a materialized view which has some precalcultaed values.
I have four dimension tables out of which one is a Time Dimension table with levels as Year->Quarter->Month.
The precalculations are the moving averages and cummulative values of Sales Amt on the dimension values over a period of 4 Months.
The dimension tables are Clients, Products, Channel, Time.
Fact Table is Sales_Fact which will have the sales amount for different members of the dimension.
Since my fact table is very huge, i want to create a materialized view where i could store the required calculated measures, here Moving Average of Sales Amt for each Client, Product, Channel dimensions over a period of 4 Months.
Can anybody help with writing the query for this..Any help in this regard will be appreciated..
Please give me suggestions for this..Check this link.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
Regards
Raj -
Encoding to output for HDTV viewing question
I would like to know what presets are best for the most prestine output to watching an encoded clip in HD. e.g. Given a HDV input, worked in FCP 5 then then encoded. What presets encoding are going to give the best results to watch on a HD monitor, and how long should it take on a G5 dual 2 for say an hour of clip? h.264 in 1080i or 720p or Mpeg4 in 1080i or 720p... consider I don't want to wait a week for encoding. I would like to know if anyone has figured general times for encoding with these conditions.
thanks in advanceI have found the answer. In capturing in dv or hdv I can encode in DVD 4 Pro once it is imported and then selecting the encoding option by right click on the dv file and chose my preset. I watch it thru a hd monitor/tv with a dvi cable and the dvd 4.6 player and it works great. So, I found a way to gather in cable tv using a canopus advc 100 720x480 of a hd program so the res is much improved going in, then process/edit and send to DVD 4 Pro. There is some loss but for home view it works great. I did find some not so know exceptions when you go to support and look for h264 encoding help and it tells some gems about how and what presets to use. I didn't find it in the manual. Also used the latest update to DVD 4 Pro 4.02.
Mike -
Explain Plan for Materialized Views in 10g
I am verifying explain plan for few queries on 10g as compared to 9i I was wondering in Materialized Views queries MAT_VIEW ACCESS instead of TABLE ACCESS is it expected behaviour or am missing something?
Couldn't find information in 10g documentation
thanks in advanceI've put together a query for the v$sql_plan in 9iR2.
Depending on what you use, you can probably drop some columns (eg OTHER and partition columns) and you could drive it from the v$session by getting the hash_value from there for the sid you are interested in :
(select * from v$sql_plan where hash_value =
(select sql_hash_value from v$session where sid=:sid))
select level, optimizer, lpad('_',1*(level-1),'_')||operation operation,
options, object_owner||'.'||object_name obj_name, search_columns,
ltrim(to_char(cardinality,'999,999,999')) no_rows,
ltrim(to_char(bytes/1024,'999,999')) kbytes, cost tot_cost,
object_node link, id, parent_id, other_tag||':'||other other,
partition_start, partition_stop, cpu_cost, io_cost,
access_predicates, filter_predicates,
round(temp_space/(1024*1024),2) temp_space_mb
from (select * from v$sql_plan where hash_value = :hash_val)
start with id=0
connect by prior id = parent_id and prior child_number = child_number
order by child_number, id, position; -
WHERE clause for Materialized View
Hi,
We are replicating a very large table from Production. The table is approx 40Gb in size and so the DBA's are very reluctant to do a full replication as it could bring down the production server (I'm a developer so I'm going on faith this is correct).
I have been looking for a way to limit the number of columns that I need, approx 1 weeks data is enough to begin with. The table has a column txntimestamp which I am trying to use in the WHERE
create materialized view FWWIPTRANSACTION
refresh fast on demand with rowid
as select * from WLOS_OWNER.WAFPROD_FWWIPTRANSACTION
where txntimestamp > '20/06/2009 07:00:00'But I recieve the error
ORA-12015: cannot create a fast refresh materialized view from a complex queryDoes anyone know a way around this? This is the only date field I can use and pretty much the only viable option to limit the number of rows.
Thank You.Sorry for jumping ahead but if I was able to get
create materialized view FWWIPTRANSACTION
refresh fast on demand with rowid
as select * from [email protected]
where txntimestamp > '20/06/2009 07:00:00';to work, does this mean every time this MV refreshes it brings across everything since that date or merely the new rows since the last refresh? If so I will need a rolling clause i.e. sysdate - 30 -
Help for materialized View & Streams.
Hi all,
I am confused....I thought streams is replacing materialized view and replication :(
What are the difference between "streams", "advance replication", and "mat. views"?
Thanks a lot,
zxyyxes2013 wrote:
I'm in a rush deadline dear :(
My boss ask me to replicate a table (with image column - picture of a person) which comes from sql server database to and oracle database.Well, presumably you informed your boss that you didn't know how to accomplish the task and that it would take some time for you to learn. And hopefully your estimates included sufficient padding to account for the fact that you'll be reading a lot of documentation.
What do I do :( . Can I use mat. views + streams + advance repl? also dbvisit? Can you use materialized views? Sure.
Can you use Streams? Sure.
You could also use GoldenGate which is the technology Oracle has depricated Streams in favor of.
I'm not sure that I see why you would want to use advanced replication unless you intend on doing bidirectional replication.
I have no idea what dbvisit is. That doesn't sound like an Oracle technology.
Justin -
How to set Inventory movement block for Material w/o phy inv document?
Hi,
I am working on an enhancement for inventory management. I have a requirement to set posting block/inventory block on a material. In doing so I don't wana create a Physical inventory document, my requirement is to set inventory block on a material without generating Physical inventory.
I am trying to use a function module MB_UPDATE_INVENTORY_DOCUMENT but this is creating a Physical inventory document.
Is there any other way of setting this block on material without having to create a Physical inventory document.
Thanks in advnce,
SAChi
in material master for a material u can set the block
go to MM02 here in basic dat 1 screen the field X-plant matl status choose entry as u need ( 01 Blocked for procment/w it will block ur inventory also)
regards
kunal -
What rights do I need for materialized views scheduling
Hello,
Can anyone tell me what rights do I need to schedule a materialized views at 1:00 am every night?
To create material views I've use the folowing script:
CREATE MATERIALIZED VIEW MV_view
REFRESH COMPLETE
START WITH sysdate NEXT round(SYSDATE + 1) + 1/24
AS SELECT ... join tabeles... ;.
The problem is that on my test server the MV_view run every night, but on production server my materialized views run only once (when I've run the script above).
I have take a look into the user_refresh and in field NEXT_DATE it's the time of my MV_view creation.
It is possible tha my DBA put some restrictions on my schema? Or do I need some rights to use START WITH and NEXT in my script on production server?
Thanks,
XaMOriginally Posted by wyld
Hi
I find the correct method: I do not only assign reporting rights to htm , I need modify "Inventory report rights"of "Administrator task" in the left of ZCC Console.
If I assign and modify the correct rights, he will create new & run these reports.
wyldkao
Which version you are using? I can't find Inventory Report Rights anywhere? I could only get this working by giving superadmin Please can some explain Thanks -
Gathering statistics for Materialized Views
In SQL Developer, the menu that you are presented by right-clicking a Materialized View does not give you a choice of collecting statistics, whereas you can analyze an MV and compute statistics at SQL command line. You can do that with the DBMS_STATS package too. Why is this so?
This is just an unintentional omission. I logged a task to get it added in our next full release.
-- Sharon -
Parameters in Init.ora for Materialized Views
Fellow Experts,
Are there any other parameters that I need to insert in the init.ora besides QUERY_REWRITE_ENABLED
and
QUERY_REWRITE_INTEGRITY
once I create a materialize view ?
Thanks.
Ray.Oracle version 10.0.2 and the DDL that I'm planning to use might be simmilar to
CREATE MATERIALIZED VIEW sales_by_month_by_state
TABLESPACE example
PARALLEL 4
BUILD IMMEDIATE
REFRESH COMPLETE
ENABLE QUERY REWRITE
AS SELECT t.calendar_month_desc, c.cust_state_province,
SUM(s.amount_sold) AS sum_sales
FROM times t, sales s, customers c
WHERE s.time_id = t.time_id AND s.cust_id = c.cust_id
GROUP BY t.calendar_month_desc, c.cust_state_province; -
EDI Output for Material Document(Application ME)
Does anybody have the experience of having set up an EDI putput for a Mmaterial Document( Application "ME")?
I tried to configure a new output type by assigning it with Program RSNASTED and routine EDI_PROCESSING.
Setting up the partner profile is still pending but when i created a test document by creating a condition record i get an error message "Purchasing document XXXXX does not exist" where XXXXX happens to be the Material document number in this case.
Before proceeding further i just want to ensure if i am using the correct programs and Routines and i havent seen any available EDI output type provided by SAP for application ME.
Appreciate your response and inputs to proceed further.
SumanDoes anybody have the experience of having set up an EDI putput for a Mmaterial Document( Application "ME")?
I tried to configure a new output type by assigning it with Program RSNASTED and routine EDI_PROCESSING.
Setting up the partner profile is still pending but when i created a test document by creating a condition record i get an error message "Purchasing document XXXXX does not exist" where XXXXX happens to be the Material document number in this case.
Before proceeding further i just want to ensure if i am using the correct programs and Routines and i havent seen any available EDI output type provided by SAP for application ME.
Appreciate your response and inputs to proceed further.
Suman
Maybe you are looking for
-
Customizing Alerts in PI 7.31/PO
Hi , We have a requirement of customizing alerts in our SAP PI 7.31 server . I just started working on it by having a glance at below blog ,but struck at getting jar files mentioned by Amit .I posted same query in blog but no response. Customize Ale
-
Run Front Row With Lid Shut?
Hi, Is it possible to run Front Row on a MacBook with the lid shut? I want to connect a MacBook to a 32" LCD TV and run Front Row on the TV screen. And ideally I'd like to be able to do that with the MacBook's lid closed.
-
Calculate freight charges in quotation
Hello, has sb. an idea how to calculate (perhaps via simulating) the freight charges at the stadium of quotation? A possible scenario has to be to calculate (simulate) the freight costs and then put it to the calculation scheme of the quotation. Than
-
Reducing polycount of 3D models?
Hey guys! I'm using CS6 (x64, windows), and I'm extruding vectors by a few points to make 3D models of decorative walls for our modelers. They've constantly told me that there are far too many polygons in the models that Photoshop generates (mine are
-
What's with this warning?
Sometimes when I've recorded an audio track in Logic Pro, I normalize the audio. When doing so, I sometimes get a warning message that the track is used in one other song, even though I know that it's not the case, as I've often just recorded it. Doe