The best method is to use dbms_metadata package:
select dbms_metadata.get_ddl(upper('&OBJ_TYPE'),upper('&OBJ_NAME'),upper('&OWNER'))
from dual;
Additional methods could be also used:
Source text of the package
select text
from dba_source
where upper(name) like upper('&which_object')
order by line ;
Use $ORACLE_HOME/bin/wrap utility to encrypt the package (there is no unwrap)
(Well, actually, there is unwrap – just look in the search machine for the words unwrap10 or rewrap…)
Source text of the views
set long 5000
col text for a80
select text from dba_views where view_name = upper('&which_view');
select query from DBA_mviews where mview_name = upper('&which_view');
SELECT view_definition FROM v$fixed_view_definition WHERE view_name='&which_view';
Source text of the synonym
select
TABLE_OWNER || '.' || TABLE_NAME
|| decode ( db_link , null , '' , '@' || db_link ) SYNONYM_OBJECT
from dba_synonyms
where SYNONYM_NAME = upper('&which_synonym');
Source text of the trigger
select
'create or replace trigger "' || trigger_name || '"'
|| chr(10)|| decode( substr( trigger_type, 1, 1 ), 'A', 'AFTER', 'B', 'BEFORE', 'I', 'INSTEAD OF' )
|| chr(10) || triggering_event || chr(10) || 'ON "' || table_owner || '"."' || table_name
|| '"' || chr(10) || decode( instr( trigger_type, 'EACH ROW' ), 0, null, 'FOR EACH ROW' )
|| chr(10) ,
trigger_body
from dba_triggers
where trigger_name = upper('&which_trigger') and owner=upper('&trigger_owner');