---
title: "一个成批删除临时表地sh用于informix"
author: "lkangjin"
date: "2008-06-23T22:57:09Z"
tags: []
slug: "sh-informix"
draft: false
lastmod: "2008-06-23T22:57:09Z"
id: 207255
url: "https://yifeng.iteye.com/blog/207255"
---

#!/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 &lt;&lt;EOF

unload to "deltmp.sql"

select tabname from systables where tabname like "tmp%" and created &lt; extend(current,year to day)

EOF

echo "load finish"

echo "| --&gt; ;"

sed 's/|/;/w deltmp1.sql' deltmp.sql

echo "tmp --&gt; 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