-- =======================================================================
-- The DBMS_METADATA package provides a way for you to retrieve metadata from the database dictionary as XML or creation DDL and to submit the XML to re-create the object.
-- =======================================================================
set line 200
set heading off;
set echo off;
Set pages 1000;
set long 70000;
spool C:\...\ddl_tablespace.sql
select dbms_metadata.get_ddl('TABLESPACE',tablespace_name) from dba_tablespaces where tablespace_name not in ('SYSTEM','SYSAUX','UNDO');
spool off
-- Example 2:
select dbms_metadata.get_ddl('TABLE','TABELAX','SCHEMA') from dual;
CREATE TABLE "SCHEMA"."TABELAX"
( "NOME" VARCHAR2(20),
"DATA" DATE
)
desc dbms_metadata;
-- -----------------------------------------------------------------------------------
-- File Name : https://oracle-base.com/dba/script_creation/view_ddl.sql
-- Author : Tim Hall
-- Description : Creates the DDL for the specified view.
-- Call Syntax : @view_ddl (schema-name) (view-name)
-- Last Modified: 16/03/2013 - Rewritten to use DBMS_METADATA
-- -----------------------------------------------------------------------------------
SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON
BEGIN
DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'SQLTERMINATOR', true);
DBMS_METADATA.set_transform_param (DBMS_METADATA.session_transform, 'PRETTY', true);
END;
/
SELECT DBMS_METADATA.get_ddl ('VIEW', view_name, owner)
FROM all_views
WHERE owner = UPPER('&1')
AND view_name = DECODE(UPPER('&2'), 'ALL', view_name, UPPER('&2'));
SET PAGESIZE 14 LINESIZE 100 FEEDBACK ON VERIFY ON
-- Font: https://oracle-base.com/dba/script?category=script_creation&file=view_ddl.sql
-- Font: https://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_metada.htm#BGBBIEGA