以前写的比较实用的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
//
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
//
相关文章推荐
- mysql56 service
- mysql show processlist 命令详解
- MySQL中Btree和Hash的局限小结
- mysql设置指定ip远程访问连接实例
- 5.6,5.7mysql zip版本 安装配置步骤
- MySql模糊查询like通配符使用详细介绍
- 'mysql' 不是内部或外部命令,也不是可运行的程序或批处理文件的解决办法
- MySQL连接及基本信息查看命令汇总
- Windows下MySQL5.7.11安装记录
- Mysql 主从复制安装指南
- MySql索引算法原理解析(通俗易懂,只讲B-tree)
- MySQL性能优化的最佳20+条经验
- Mysql 优化 Notes
- MYSQL数据类型优化
- Mysql中组合的insert和update语句
- MySQL中的级联约束
- MySQL将查询结果输出都爱服务器文件中
- MYSQL优化
- mysql 备份与还原
- arch安装mysql