hp-ux下用shell生成sql语句...
时间:2010-08-15 来源:rolinzcy12
#!/usr/bin/ksh
# This is for HPC users data
targ_dir=/space/mm/zhaochy
prog_dir=$targ_dir"/prog"
result_dir=$targ_dir"/result"
nowdate=`$prog_dir/date_sql.sh`
echo set heading off > $prog_dir/hpc_month_data.sql
echo set pagesize 0 >> $prog_dir/hpc_month_data.sql
echo set linesize 200 >> $prog_dir/hpc_month_data.sql
echo set trimout on >> $prog_dir/hpc_month_data.sql
echo set trimspool on >> $prog_dir/hpc_month_data.sql
echo set feedback off >> $prog_dir/hpc_month_data.sql
echo spool $result_dir"/"hpc_month_data.txt >> $prog_dir/hpc_month_data.sql
echo select owner,SUM"("filesize")/"1024"/"1024"/"1024 from BACKUP_ARCHIVE_DATA_LIST where backup_time LIKE "'""$nowdate""%'" group by owner";" >> $prog_dir/hpc_month_data.sql
echo spool off >> $prog_dir/hpc_month_data.sql
echo exit >> $prog_dir/hpc_month_data.sql
# cat hpc_month_data.sql
set heading off
set pagesize 0
set linesize 200
set trimout on
set trimspool on
set feedback off
spool /space/mm/zhaochy/result/hpc_month_data.txt
select owner,SUM(filesize)/1024/1024/1024 from BACKUP_ARCHIVE_DATA_LIST where backup_time LIKE '201007%' group by owner;
spool off
exit