說明:IbosExecHistory系列表是提供歷史數(shù)據(jù)查詢的歷史表;
IbosExecHistory為試圖;
IbosExecHistory_XXXX中“XXXX”為年份,供存放該年所有歷史數(shù)據(jù),此類表做歷史數(shù)據(jù)備份用,不提供維護系統(tǒng)查詢;
IbosExecHistory_month_X中“X”為月份(1-9不加0),此類表做循環(huán)使用,根據(jù)維護系統(tǒng)要求查詢時提供6個月內(nèi)數(shù)據(jù),故在此前六個月之外的數(shù)據(jù)可清楚。最后及時清楚,否則將造成與往年數(shù)據(jù)共存現(xiàn)象,較難分離。若造成累計,建議將數(shù)據(jù)使用bcp導出后,對文件進行操作,不要在數(shù)據(jù)庫中進行操作。
工作原理:為減少對數(shù)據(jù)庫性能造成影響,使用bcp和truncate table操作,做truncate table時應謹慎。
本文目的:提供IbosExecHistory_month_X表歷史數(shù)據(jù)清除步驟。
注:以下步驟以2010年5月份歷史數(shù)據(jù)清除為例,在實際操作中需更改重要sql語句,謹記。
具體步驟:
1.查詢年份表中是否已有該月數(shù)據(jù),結(jié)果為0,則順序執(zhí)行
select count(*) from IbosExecHistory_2010 where SendTime>='2010-05-01' and SendTime<'2010-06-01'
2.查詢月份表中是否已清除,結(jié)果不為0,則順序執(zhí)行
select count(*) from IbosExecHistory_month_5
3.使用bcp命令進行數(shù)據(jù)導出,bcp命令OS命令,在已安裝sybase數(shù)據(jù)庫客戶端的系統(tǒng)上方可使用
bcp test..IbosExecHistory_month_5 out d:\IbosExecHistory_month_5.txt -c -t "{" -r "\r\n" -Uibos -Pibos123 -Stfh28
4.使用bcp命令進行數(shù)據(jù)導入
bcp test..IbosExecHistory_2010 in d:\IbosExecHistory_month_5.txt -c -t "{" -r "\r\n" -Uibos -Pibos123 -Stfh28
5.清除月份表數(shù)據(jù)
truncate table IbosExecHistory_month_5
posted on 2010-12-22 15:54
身在半空 閱讀(291)
評論(0) 編輯 收藏