Site icon EasyOraDBA

Generate Excel | CSV Report from SQL*PLUS

Shell Script to generate a column seperator report in SQL*PLUS using a shell script. It can be opened in Excel and or text editor like NOTEPAD++

. $HOME/.bash_profile
NOW=$(date +”%a %b %e %T %Y”)
MON2=$(date +”%b%Y”)
cd $HOME/scripts
rm -rf Report_$MON2.csv
sqlplus -s /NOLOG << EOF > /tmp/log.txt
CONNECT abc/*****
set colsep ;
set pagesize 1000
set trimspool on
set headsep off
set linesize 9999
alter session set nls_date_format = ‘DD/MM/YYYY’;
spool Report_$MON2.csv
select * from tablename where condition;
spool off


Exit mobile version