一个批量删除临时表的sh用于informix


#!/bin/csh

if ($#argv != 1 then

echo "Usage:csh deltmp.sh [dbname]";

exit(0);

else if ($#argv == 1 then

set dbname="$argv[1]";

endif

rm deltmp*.sql

echo "now load tmp table to deltmp.sql"

dbaccess $dbname <

 1<eof "deltmp.sql"="" "load="" "tmp%"="" "|="" --="" <="" and="" created="" day)="" echo="" eof="" extend(current,year="" finish"="" from="" like="" select="" systables="" tabname="" to="" unload="" where=""> ;"   
 2  
 3sed 's/|/;/w deltmp1.sql' deltmp.sql   
 4  
 5echo "tmp --&gt; drop table tmp"   
 6  
 7sed 's/tmp/drop table tmp/w deltmp2.sql' deltmp1.sql   
 8  
 9echo "delete temp table"   
10  
11dbaccess $dbname deltmp2.sql   
12  
13echo "delele temp files"   
14  
15rm deltmp*.sql</eof>
Published At
Categories with 数据库类
comments powered by Disqus