Monday, June 11, 2012

dbms_metadata.get_ddl in oracle

select dbms_metadata.get_ddl( 'TABLE','TABLE_NAME','SCHEMA_NAME') from dual;

to format the output in sqlplus:


set long 200000 pages 0 lines 2000
column txt format a2000 word_wrapped
spool trigger_ddl_n.sql
select dbms_metadata.get_ddl( 'TRIGGER',Trigger_name,upper('test')) txt
from
dba_triggers
where trigger_name in
(select trigger_name from dba_triggers where owner=upper('test')
minus
select trigger_name from dba_triggers where owner=upper('test1')
)
and owner=upper('test')
;
spool off


reference:
http://pages.videotron.com/orautils/pages/dbms_metadata.htm
http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_metada.htm
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:30802454515375

No comments:

Post a Comment