具體要求是這樣的
有兩張表 歷史表 當月表 兩張表的表結構完全一致
每月月初將上一個月的表資料匯出到歷史表 當月表清空
具體該怎么做呢?
uj5u.com熱心網友回復:
服務器定時腳本 月初執行一次事務匯出匯入excel
完成以后清空當月表
uj5u.com熱心網友回復:
每月做你可以用 event 或者作業系統的定時任務移資料可以參考這個( 建一個相同結構的當前表替換在用的當前表,然后把資料寫到歷史表)
create table _當月表 LIKE 當前表;
rename table 當前表 to _歷史表, _當月表 to 當月表;
insert 歷史表 select * from _歷史表;
drop table _歷史表;
uj5u.com熱心網友回復:
結帖率:0%
當您的問題得到解答后請及時結貼.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html
8、如何給分和結貼?
http://bbs.csdn.net/help#post_dispose
uj5u.com熱心網友回復:
這個你可以用mysql的event功能來做。你可以把具體的操作:insert into 歷史表 select * from 實時表 where 上月資料 ,然后delete from 事實表 where上月資料,放到一個存盤程序里,然后放到event里呼叫這個存盤程序就行了
uj5u.com熱心網友回復:
當你的兩張表資料結構一模一樣的話,可以使用 insert into 目標表 select * from 源表 然后洗掉目標表的資料,最后在用一個定損任務來定時執行就可以了,就是樓上所說的mysql的event ,感謝樓上所說的event 正好學習下uj5u.com熱心網友回復:
-- 歷史表:History_Table,當月表: Current_Table;用mysql的event功能來做:
Create TABLE Current_Table1 LIKE Current_Table;
INSERT INTO History_table SELECT * FROM Current_Table;
DROP TABLE Current_TABLE;
RENAME TABLE Current_Table1 To Current_Table;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/109460.html
標籤:MySQL
上一篇:select 復合查詢
