如何獲取物化視圖的ddl語句呢

如何獲取物化視圖的ddl語句呢

 

我建立了一個物化視圖,以下,時間久了,忘了物化視圖的定義了 ,在哪裏去找呢:對象

CREATE MATERIALIZED VIEW cust_sales_mvblog

ENABLE QUERY REWRITE ASget

SELECT c.cust_id, SUM(amount_sold)input

FROM sales s, customers cio

WHERE s.cust_id = c.cust_idfunction

GROUP BY c.cust_id;object

我經過select object_name,object_type from dba_objects where object_name='CUST_SALES_MV';select

SQL> select object_name,object_type from dba_objects where object_name='CUST_SALES_MV';meta

OBJECT_NAME OBJECT_TYPEim

------------------------------ -------------------

CUST_SALES_MV TABLE

CUST_SALES_MV MATERIALIZED VIEW

在經過get_ddl語句報類型不對:

SQL> SELECT dbms_metadata .get_ddl('MATERIALIZED VIEW','CUST_SALES_MV','SH')

2 from dual;

ERROR:

ORA-31600: invalid input value MATERIALIZED VIEW for parameter OBJECT_TYPE in function GET_DDL

ORA-06512: at "SYS.DBMS_METADATA", line 5805

ORA-06512: at "SYS.DBMS_METADATA", line 8344

ORA-06512: at line 1

no rows selected

看來不能直接使用 'MATERIALIZED VIEW',怎麼辦呢

中間加上_試試:

SQL> SELECT dbms_metadata .get_ddl('MATERIALIZED_VIEW','CUST_SALES_MV','SH')

2 from dual ;

DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','CUST_SALES_MV','SH')

--------------------------------------------------------------------------------

CREATE MATERIALIZED VIEW "SH"."CUST_SALES_MV" ("CUST_ID", "SUM(AMOUNT_SOLD)")

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

DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW','CUST_SALES_MV','SH')

--------------------------------------------------------------------------------

PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1

BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)

TABLESPACE "USERS"

REFRESH FORCE ON DEMAND

USING DEFAULT LOCAL ROLLBACK SEGMENT

USING ENFORCED CONSTRAINTS ENABLE QUERY REWRITE

AS SELECT c.cust_id, SUM(amount_sold)

FROM sales s, customers c

WHERE s.cust_id = c.cust_id

GROUP BY c.cust_id

出來了,看來對象類型中間不能有空格.

相關文章
相關標籤/搜索