我正在开展一项相当复杂且时间关键的数据转换。 这是通过使用存储过程实现的。
最近的更改请求要求我更新此存储过程。为了安全地这样做,我创建了一个包含数据的完整模式转储,并将其导入到两个不同的模式中。一个名为“原创”的原作'还有一个名为“修改过来的”。
在更新实时数据库之前,我试图比较原始数据库和修改数据库的输出,以识别已添加的数据,并且没有丢失数据。
不幸的是我的测试系统正在运行MySQL v 5.7.12-0ubuntu-1而我的实时服务器是运行5.6.30的CentOS服务器。
原始数据库中的group子句(与live相同)引发了一个问题(在live上不存在)。此错误(1055 - SELECT列表的表达式#5不在GROUP BY子句中并包含非聚合列)完全有意义,并在修订的数据库中得到解决。我只想进行比较而无需在此开发服务器上安装完全相同版本的MySQL。
我尝试从sql_mode参数中删除ONLY_FULL_GROUP_BY
,并将两台服务器上的sql_mode仅匹配为NO_ENGINE_SUBSTITUTION
有人可以帮忙吗?查询如下:
Insert into skeleton_football (
sport_id,
parent_event_id,
event_id,
event_part_id,
back_outcome_id,
lay_outcome_id,
start_time,
market_type,
competition_name,
event_name,
event_part_name,
outcome_name,
outcome_value
)
SELECT
sp.id as `sport_id`,
if (ev.name is null, pev.id, null) as `parent_event_id`,
ev.id as `event_id`,
evp.id as `event_part_id`,
oc.back_outcome_id as back_outcome_id,
oc.lay_outcome_id as lay_outcome_id,
#oc.param_float_1,
#oc.param_float_2,
#oc.param_float_3,
#oc.param_boolean_1,
#oc.param_string_1,
#oc.param_participant_id_1,
#oc.param_participant_id_2,
#oc.param_participant_id_3,
#oc.param_event_part_id_1,
ev.start_time as start_time,
sp.name as market_type,
if (ev.name is null, pev.name, ev.name) as competition_name,
if (sp.name = "football",concat(epah.name, " v ", epaa.name),ev.name) as event_name,
evp.name as event_part_name,
oct.name as outcome_name,
get_outcome_value(
oct.name,
oc.param_participant_id_1,
max(epah.id),
max(epah.name),
max(epaa.id),
max(epaa.name),
opa.id,
opa.name,
oc.param_float_1,
oc.param_float_2,
oc.param_boolean_1
) as outcome_value
FROM raw_event ev
left join raw_event pev on pev.id = ev.parent_id
inner join raw_sport sp on ev.sport_id = sp.id
inner join config_events_filter cef on cef.sport_id = sp.id and (cef.competition_name is null or pev.name like cef.competition_name)
left join outcome_matched oc on ev.id = oc.event_id
inner join raw_event_part evp on evp.id = oc.event_part_id and evp.name in ("ordinary time", "whole match", "whole event")
cross join raw_participant_role prh on prh.name ="home"
cross join raw_participant_role pra on pra.name = "away"
cross join raw_participant_role pro on pro.name not in ("home", "away")
left join raw_event_participant_relation pera on pera.event_id = ev.id and pra.id = pera.participant_role_id
left join raw_event_participant_relation perh on perh.event_id = ev.id and prh.id = perh.participant_role_id
left join raw_event_participant_relation pero on pero.event_id = ev.id and pro.id = pero.participant_role_id
left join raw_outcome_type oct on oc.type_id = oct.id
left join raw_participant epaa on pera.participant_id = epaa.id
left join raw_participant epah on perh.participant_id = epah.id
left join raw_participant epao on pero.participant_id = epao.id
#left join raw_participant epap on per.participant_id = epap.id and pr.name not in ("home", "away")
left join raw_participant opa on oc.param_participant_id_1 = opa.id
where ev.start_time > date_sub('2016-05-11 14:00:00', INTERVAL 1 HOUR)
and ev.start_time < date_add('2016-05-11 14:00:00', INTERVAL 2 DAY)
group by sp.id, ev.id, evp.id, oc.back_unique, if (sp.name = "football",concat(epah.name, " v ", epaa.name),ev.name)
having event_name is not null;