以前寫的比較實用的mysql代碼[1]

SHOW variables LIKE 'event_scheduler';


USE today;
CREATE EVENT e_clear
ON SCHEDULE EVERY 1 DAY STARTS '2015-09-10 9:27:00'
DO TRUNCATE TABLE today.tb_stop;


CREATE EVENT e_shinsert
ON SCHEDULE EVERY 1 DAY STARTS '2015-09-10 9:28:00'
DO INSERT into today.tb_stop 
  SELECT 1,instrument FROM today.tb_quote_ssh where PrevPrice=LastPrice and AskPrice1=0 and BidPrice1=0 and instrument >= 600000;


SELECT EXCHANGE,count(*) FROM today.tb_stop GROUP BY EXCHANGE;
select * from today.tb_stop where exchange=2;
drop event e_test;
drop event e_shinsert;
drop event e_szinsert;
select * from today.tb_stop;
select * from MP_POSITION_HISTORY; -- truncate table MP_POSITION_HISTORY;


select * from MP_POSITION_HISTORY order by date;
select * from MP_POSITION_HISTORY where date=20150914;
create TABLE TEST;
delete from MP_POSITION_HISTORY where date=20151117;
select * from my_position where stockName like 'ST';


insert into MP_POSITION_HISTORY (account,exchange,instrument,size,price,date) select *,current_date()+0 from MP_POSITION;


USE today;
delimiter //
drop event if exists e_test;//
CREATE EVENT e_test
ON SCHEDULE EVERY 1 DAY STARTS '2015-09-10 09:27:00' on completion preserve enable
DO 
BEGIN
TRUNCATE TABLE today.tb_stop;
INSERT into today.tb_stop 
 SELECT 1,instrument FROM today.tb_quote_ssh where PrevPrice=LastPrice and AskPrice1=0 and BidPrice1=0 and instrument >= 600000 ;
insert into today.tb_stop 
 SELECT 2,instrument FROM today.tb_quote_ssz where PrevPrice=LastPrice and AskPrice1=0 and BidPrice1=0 and instrument <= 2999
 union all
 SELECT 2,instrument FROM today.tb_quote_ssz where PrevPrice=LastPrice and AskPrice1=0 and BidPrice1=0 and instrument >= 300000 and instrument <= 300999;
end
//
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章