rds - mysql修改存储过程/函数的方式

rds 不支持账户A 给账户B 创建授权存储过程,只能是当前登录账户给自己创建,要登陆对应账户删除原有存储过程重新创建即为修改。

 

例子如下:

先登陆新账号然后执行如下sql语句即可:

DROP PROCEDURE IF EXISTS `sp_channel_report`;
CREATE DEFINER = CURRENT_USER PROCEDURE `sp_channel_report`()
BEGIN
    
    set @largeLoan = 10007;
    set @today = curdate();
    
    select concat('[',group_concat(concat('{"name":"',a.name,
        '","largeLoanAccessTotal":',(select count(type) from access_url_log where type=0 and dc_id=a.id and upi_id=@largeLoan),
        ',"largeLoanClickTotal":',(select count(type) from access_url_log where type=1 and dc_id=a.id and upi_id=@largeLoan),
        ',"loanEntranceClickTotal":',(select count(type) from access_url_log where type=1 and dc_id=a.id and upi_id>@largeLoan and to_days(create_time)=to_days(now())),
        ',"loanEntranceAccessTotal":',(select count(id) from (select id,dc_id from access_url_log where type=0 and upi_id>@largeLoan group by dc_id,ip_addr) t where dc_id=a.id),
        ',"todayUserAccessTotal":', (select count(dc_id) from (select dc_id,ip_addr from access_url_log where create_time>=@today and upi_id>@largeLoan group by dc_id,ip_addr) t where dc_id=a.id),
        '}')), ']') as str
    from download_channel a;
    
END;

 

posted @ 2019-08-08 16:57  007少侠  阅读(582)  评论(0编辑  收藏  举报
友情链接:便宜vps(CN2GIA线路)
站长统计: