set termout on
accept output_file_name prompt 'Enter Output File Name: '
set termout off
set pages 0
set lines 256
set long 4096
set longc 4096
set wrap on
set recsep off
set feedback off
set verify off
set trimspool on
spool &&output_file_name
prompt
prompt USER$ Data
prompt

select '"name","account_status","password","spare4"' from dual;
select '"'||name||'","'||account_status||'","'||u.password||'","'||spare4||'"' from user$ u, dba_users
where spare4 is not null
and username = name;

prompt
prompt V$SESSION Data
prompt

select '"username","schemaname","osuser","machine","terminal","program","type","logon_time","service_name","sql_trace"' from dual;
select '"'||username||'","'||schemaname||'","'||osuser||'","'||machine||'","'||terminal||'","'||program||'","'||type||'","'||logon_time||'","'||service_name||'","'||sql_trace||'"' from v$session
where username is not null ;

prompt
prompt DBA_SEGMENTS Data
prompt

select '"Total_MBytes"' from dual;
select sum(bytes)/1024/1024 mbytes from dba_segments
where owner = 'SAAOWNER'
and (segment_name like 'MESG%'
or segment_name like 'APPE%'
or segment_name like 'TEXT%');

prompt
prompt SWIFT_DATES In Database
prompt

select '"SWIFT_Dates_In_Database"' from dual;
select substr(table_name,6,20) SWIFT_Dates_In_Database
from all_tables
where owner = 'SAAOWNER'
and table_name like 'MESG%'
and table_name not like '%YYYYMMDD%'
order by 1 desc
/

spool off
set termout on
prompt 
prompt 
prompt Done!
prompt 
prompt 
prompt 
exit
