版权声明:本文为博主九师兄(QQ群:spark源代码 198279782 欢迎来探讨技术)原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_21383435/article/details/82286132
该方法,能在保持原有代码的情况下,比如大小写,换行,缩进等信息,去除sql中的各种注释
代码如下
Pattern p = Pattern.compile("(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/|#.*?$|");
String presult = p.matcher(sql).replaceAll("$1");
return presult;
包括
横杠注释
--drop table report.rpt_employee_fund_match;
--create table report.rpt_employee_fund_match as
/* insert into report.partner_open_account_stat_tmp
-- where to_number(to_char(a.create_date,'YYYYMMDD'),'99999999') <= v_period_id
*/ -- delete by zak 20140623
包括不去掉原有代码里面的注释,非常强大
select employee_id, max(cast(organization_id as integer))
organization_id
from src_ht_hr_ims.ims_rt_employee_organization where state=1
and jobtitle <>'--' --and employee_id='50019940'
group by employee_id