LOG_ID,LOG_CONTENT,FOREIGN_KEY_ID,FOREIGN_KEY_TYPE select from log_result t.${col.trim()} select from log_result t and LOG_ID=#{logId} and LOG_CONTENT=#{logContent} and FOREIGN_KEY_TYPE=#{foreignKeyType} -- 2.重复字段的硬编译,用循环来优化 and ALTERNATE_FIELDS${index +1}=#{field} and LOG_ID=#{logId} -- 3.直接拼接会存在SQL注入的风险 and LOG_CONTENT like concat('%',#{logContent},'%') and FOREIGN_KEY_ID=#{foreignKeyId} and FOREIGN_KEY_TYPE like concat('%','foreignKeyType','%') and TO_CHAR(INSERT_TIME,'yyyy-mm-dd')=#{insertTime} and DATAGRAM${index+1} like concat('%','field','%') and ALTERNATE_FIELDS${index+1} like concat('%','field','%') delete from LOG_RESULT where LOG_ID=#{logId,jdbcType=DECIMAL} delete from LOG_RESULT where 1!=1 or LOG_CONTENT=#{logContent} or DATAGRAM${index+1} =#{field} insert into LOG_RESULT(LOG_ID,LOG_CONTENT,FOREIGN_KEY_ID,FOREIGN_KEY_TYPE) values(#{logId},#{logContent},#{foreignKeyId},#{foreignKeyType}}) insert into LOG_RESULT LOG_ID, LOG_CONTENT, FOREIGN_KEY_ID, FOREIGN_KEY_TYPE, ALTERNATE_FIELDS${index+1}, #{logId} #{logContent} #{foreignKeyId} #{foreignKeyType} #{field} update LOG_RESULT set LOG_CONTENT=#{logContent}, FOREIGN_KEY_ID=#{foeignKeyId}, FOREIGN_KEY_TYPE= #{foreignKeyType} where LOG_ID=#{logId} update LOG_RESULT LOG_CONTENT=#{logContent} FOREIGN_KEY_ID= #{foreignKeyId} FOREIGN_KEY_TYPE= #{foreignKeyType} ALTERNATE_FIELDS${index+1}=#{field} where LOG_ID = #{logId} delete from LOG_RESULT where LOG_ID in #{id}