#!/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 <<EOF
unload to "deltmp.sql"
select tabname from systables where tabname like "tmp%" and created < extend(current,year to day)
EOF
echo "load finish"
echo "| -->; ;"
sed 's/|/;/w deltmp1.sql' deltmp.sql
echo "tmp -->; drop table tmp"
sed 's/tmp/drop table tmp/w deltmp2.sql' deltmp1.sql
echo "delete temp table"
dbaccess $dbname deltmp2.sql
echo "delele temp files"
rm deltmp*.sql
ciscoboy 回复于:2003-11-13 16:53:49
不错,稍微改动一下可以进行批量表的删除了,不知道高手有没有批量删除一个表中的大量数据的存储过程?有的话能不能共享一下,谢了!
czw1413_cn 回复于:2003-11-13 18:25:04
确实写的不错
大梦 回复于:2003-11-14 09:01:32
呵呵~~~
临时表一般下次启动时就自动删除了的~~~
|