avatar

通过MYSQL的触发器备份需要删除的数据到其他的表中(例)

delimiter //
CREATE Trigger BackUp_Old_AcctTbl AFTER DELETE on radacct
FOR EACH ROW BEGIN
INSERT INTO radacct_backup (radacctid,acctsessionid,acctuniqueid,username,groupname,realm,nasipaddress,nasportid,

nasporttype,acctstarttime,acctstoptime,acctsessiontime,acctauthentic,connectinfo_start,connectinfo_stop,

acctinputoctets,acctoutputoctets,calledstationid,callingstationid,acctterminatecause,servicetype,framedprotocol,framedipaddress,

acctstartdelay,acctstopdelay,xascendsessionsvrkey,_accttime,_srvid,_dailynextsrvactive,_apid)

VALUES (old.radacctid,old.acctsessionid,old.acctuniqueid,old.username,old.groupname,old.realm,old.nasipaddress,old.nasportid,

old.nasporttype,old.acctstarttime,old.acctstoptime,old.acctsessiontime,old.acctauthentic,

old.connectinfo_start,old.connectinfo_stop,old.acctinputoctets,old.acctoutputoctets,old.calledstationid,old.callingstationid,

old.acctterminatecause,old.servicetype,old.framedprotocol,old.framedipaddress,old.acctstartdelay,

old.acctstopdelay,old.xascendsessionsvrkey,old._accttime,old._srvid,old._dailynextsrvactive,old._apid);
END;
//
delimiter ;

同理可以备份SS表中的每月流量数据

delimiter //
CREATE Trigger BackUp_Old_SSTbl AFTER UPDATE on user

FOR EACH ROW
BEGIN
IF new.u =’0′ AND new.d = ’0′ THEN

INSERT INTO user_backup (email,pass,passwd,t,u,d,transfer_enable,port,switch,enable,type,deldate)

VALUES (old.email,old.pass,old.passwd,old.t,old.u,old.d,old.transfer_enable,

old.port,old.switch,old.enable,old.type,NOW());

END IF;

END;
//
delimiter ;

Comments ( 0 ) Leave a Reply
  1. No comments yet.

    目前尚无任何评论.

    コメントはまだありません。

  2.                    
  • ☆*:.。. o(≧▽≦)o .。.:*☆
  • _(:з」∠)_
  • ♪(´ε` )
  • ψ(`∇´)ψ
  • (-_-#)
  • (=´∀`)人(´∀`=)
  • \(//∇//)\
  • ♪(*^^)o∀*∀o(^^*)♪
  • (((o(*゚▽゚*)o)))
  • (´・_・`)
  • σ(^_^;)
  • ( *`ω´)
  • (ノ`Д´)ノ
  • (( _ _ ))..zzzZZ
  • ( ̄▽ ̄)
  • ヽ(`Д´#)ノ
  • ((((;゚Д゚)))))))
  • (>_<)
  • (T_T)
  • ( T_T)\(^-^ )
  • ε=ε=ε=ε=ε=ε=┌(; ̄◇ ̄)┘