Sql语句积累

2018/10/26

工作中涉及到的sql语句

  1. 修改用户名 ``` update xtp_user set user_pass=md5(‘123123’);

select * from ‘xtp_user’where trade_server_id =3;


2. 批量更改数据库表名:

SELECT CONCAT( ‘ALTER TABLE ‘, table_name, ‘ RENAME TO ‘, REPLACE(table_name, ‘1024’, ‘1025’), ‘;’ ) FROM information_schema.TABLES WHERE table_schema = ‘xtp8’ and table_name LIKE ‘%20181024’

 底下结果栏会查询出具体的修改表名的SQL语句,复制进行执行

 3.
 早上xtp88数据库初始化

DELETE FROM xtp_opt_exch_sec_20181026 WHERE instrument_id IN (SELECT cntrt_id FROM xtp_opt_cntrt_info_20181026 WHERE tgt_stk_code IN (‘510900’,’513030’,’513050’,’513100’,’513500’,’513600’,’513660’,’512160’)); DELETE FROM xtp_derivative_auction_params_20181026 WHERE security_id IN (SELECT cntrt_id FROM xtp_opt_cntrt_info_20181026 WHERE tgt_stk_code IN (‘510900’,’513030’,’513050’,’513100’,’513500’,’513600’,’513660’,’512160’,’512160’));

DELETE FROM xtp_opt_cntrt_info_20181026 WHERE tgt_stk_code IN (‘510900’,’513030’,’513050’,’513100’,’513500’,’513600’,’513660’,’512160’,’512160’);

INSERT INTO xtp_opt_position_limit_20181026 SELECT DISTINCT a.fund_acc,a.market,b.stkcode,b.secutype,2000,1000,4000 FROM xtp_opt_position_limit_20181026 a,opt_limit_less b; ```

Search

    欢迎关注我的微信公众号

    晨枫

    alex0227

    Table of Contents