Friday, May 5, 2017

individually generate ddl for each object


If you want to individually generate ddl for each object,

Queries are:
--GENERATE DDL FOR ALL USER OBJECTS
--1. FOR ALL TABLES
SELECT DBMS_METADATA.GET_DDL('TABLE', TABLE_NAME) FROM USER_TABLES;
--2. FOR ALL INDEXES
SELECT DBMS_METADATA.GET_DDL('INDEX', INDEX_NAME) FROM USER_INDEXES WHERE INDEX_TYPE ='NORMAL';
--3. FOR ALL VIEWS
SELECT DBMS_METADATA.GET_DDL('VIEW', VIEW_NAME) FROM USER_VIEWS;
OR
SELECT TEXT FROM USER_VIEWS
--4. FOR ALL MATERILIZED VIEWS
SELECT QUERY FROM USER_MVIEWS
--5. FOR ALL FUNCTION
SELECT DBMS_METADATA.GET_DDL('FUNCTION', OBJECT_NAME) FROM USER_PROCEDURES WHERE OBJECT_TYPE = 'FUNCTION'
===============================================================================================
GET_DDL Function doesnt support for some object_type like LOB,MATERIALIZED VIEW, TABLE PARTITION
SO, Consolidated query for generating DDL will be:
SELECT OBJECT_TYPE, OBJECT_NAME,DBMS_METADATA.GET_DDL(OBJECT_TYPE, OBJECT_NAME, OWNER)
FROM ALL_OBJECTS
WHERE (OWNER = 'XYZ') AND OBJECT_TYPE NOT IN('LOB','MATERIALIZED VIEW', 'TABLE PARTITION') O

No comments:

Post a Comment

How to install and configure Oracle Apex 24.1 with ORDS 22, Tomcat 9 and Jasper Report 7 on Oracle Linux 8.10

#########################Install Oracle  APEX 24.1################################ ----------------------------------------------------...