例如,下列查詢取得某些SEQUENCE的定義
SELECT dbms_metadata.get_ddl (object_type, object_name, USER)
FROM user_objects
WHERE object_type LIKE 'SEQUENCE' AND
object_name LIKE '%TEMPLATE%';
上述查詢共有六個SEQUENCE,每個均以 CLOB 型態儲存
點開物件即可看到定義的物件
另外一種方式,取得TABLE物件的定義
將下列程式碼使用TOAD執行 (PLSAL視窗)
DECLARE v_hnd NUMBER; v_th NUMBER; v_sql CLOB; BEGIN v_hnd := DBMS_METADATA.OPEN('TABLE'); DBMS_METADATA.SET_FILTER(v_hnd, 'SCHEMA','HR'); DBMS_METADATA.SET_FILTER (v_hnd, 'NAME','NEW_EMPLOYEES'); v_th := DBMS_METADATA. ADD_TRANSFORM (v_hnd,'MODIFY'); DBMS_METADATA.SET_REMAP_PARAM(v_th,'REMAP_SCHEMA','HR','DAVID'); /* 會將原有的 HR.NEW_EMPLOYEES 表格,匯出成為 DAVID.NEW_EMPLOYEES */ v_th := DBMS_METADATA.ADD_TRANSFORM(v_hnd,'DDL'); DBMS_METADATA.SET_TRANSFORM_PARAM(v_th,'SEGMENT_ATTRIBUTES',false); v_sql := DBMS_METADATA.FETCH_CLOB(v_hnd); DBMS_METADATA.close(v_hnd); DBMS_OUTPUT.PUT_LINE(v_sql); END;執行結果如圖所示