問題:
查詢一個數據,需要的時間比較長,可能要跑幾個小時,用ssh連接遠端數據庫執行查詢命令後在查詢過程中不能斷開連接
如果斷線一下,ssh與遠端服務器斷開後,遠端服務器執行的sqlplus進程就會被關閉,然後數據查詢就會中斷,就出現問
題前功盡棄了。
想辦法;通過編寫腳本實現
腳本:
vi /home/oracle/auto.sh
#!/bin/bash
# connect to the datebase and perform the sql script select.sql
sqlplus poi/crutrty @select.sql
sql腳本
vi /home/oracle/select.sql
insert into tptb0 select distinct c.setto from tuselist_his c,tmmsc d where length(c.setto)>7 and d.areacode='769' and c.SENDTIME between to_date('01012008','mmddyyyy') and to_date('10222008','mmddyyyy') ;
commit;
執行
nohup sh /home/oracle/auto.sh &
然後就下線去吧