您的位置:首页 > 数据库 > MySQL

以前写的比较实用的mysql代码[1]

2016-02-16 09:26 489 查看
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

//
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: