问题提出:
表user_experience_wealth_log改名为user_experience_wealth_log_new,该表涉及若干存储过程。为了避免遗漏,需要确认所有相关过程都做了修改,验证方法为不存在包含user_experience_wealth_log的存储过程。
问题分析:
不能使用简单的 not like ‘%user_experience_wealth_log%’,因为这样也会过滤掉包含user_experience_wealth_log_new的记录。使用rlike的正则表达式即可轻松解决。
查询语句:
-- 只包含user_experience_wealth_log_new
select routine_schema,routine_name from routines
where routine_type='procedure'
and routine_definition rlike 'user_experience_wealth_log_new'
and routine_definition not rlike 'user_experience_wealth_log[^_]';
-- 只包含user_experience_wealth_log
select routine_schema,routine_name from routines
where routine_type='procedure'
and routine_definition rlike 'user_experience_wealth_log[^_]'
and routine_definition not rlike 'user_experience_wealth_log_new';
-- 两个都包含
select routine_schema,routine_name from routines
where routine_type='procedure'
and routine_definition rlike 'user_experience_wealth_log_new'
and routine_definition rlike 'user_experience_wealth_log[^_]';