DBMS_METADATA.GET_DDL
###Pulling out the Source code/extracting the code We have DBMS_METADATA.GET_DDL Handy to complete the task. set pagesize 0 set long 90000 SELECT DBMS_METADATA.GET_DDL('PACKAGE',' ') FROM dual; To extract package body definition from database: set pagesize 0 set long 90000 SELECT DBMS_METADATA.GET_DDL('PACKAGE_BODY',' ' ) FROM dual; To extract user definition: set pagesize 0 set long 100000 select dbms_metadata.get_ddl( 'USER', ' ' ) from dual UNION ALL select dbms_metadata.get_granted_ddl( 'SYSTEM_GRANT', ' ' ) from dual UNION ALL select dbms_metadata.get_granted_ddl( 'OBJECT_GRANT', ' ' ) from dual UNION ALL select dbms_metadata.get_granted_ddl( 'ROLE_GRANT', ' ' ) from dual; To extract tablespace definition: SELECT dbms_metadata.get_ddl('TABLESPACE','&&tbs_name') FROM dual; To extract table definition: SELECT dbms_metadata.get_ddl('TABLE',upper(