当前位置: 代码迷 >> 综合 >> Oracle_SQL:数据查询过程中SQL技巧总结(持续更新中)
  详细解决方案

Oracle_SQL:数据查询过程中SQL技巧总结(持续更新中)

热度:79   发布时间:2023-12-13 02:06:27.0

目录

  • 1: 如何计算两字段中字符串的相似程度?
    • 涉及函数(11gR2)
    • UTL_MATCH函数简介
      • Edit Distance 概念
      • Jaro-Winkler 概念
    • 应用举例
      • UTL_MATCH.EDIT_DISTANCE
        • 英文处理
        • 中文处理(支持不好)
      • UTL_MATCH.EDIT_DISTANCE_SIMILARITY
        • 英文处理
        • 中文处理(支持不好)
      • UTL_MATCH.JARO_WINKLER
        • 英文处理
        • 中文处理(支持不好)
      • UTL_MATCH.JARO_WINKLER_SIMILARITY
        • 英文处理
        • 中文处理(支持不好)

1: 如何计算两字段中字符串的相似程度?

有时候我们需要对比两个字段相似程度,Oracle提供一个函数用于使用。

涉及函数(11gR2)

UTL_MATCH 的4个子程序来进行处理(subprogram)

Subprogram Description
EDIT_DISTANCE Calculates the number of changes required to transform string-1 into string-2 计算字符串string-1 转成string-2需要做几次改变
EDIT_DISTANCE_SIMILARITY Calculates the number of changes required to transform string-1 into string-2, returning a value between 0 (no match) and 100 (perfect match) 计算字符串string-1 转成string-2需要做改变的次数,剩下的值,0代表没有一个字符匹配,100代表完全匹配
JARO_WINKLER Calculates the measure of agreement between string-1 and string-2 计算字符串1和字符串2之间的一致程度
JARO_WINKLER_SIMILARITY Calculates the measure of agreement between string-1 and string-2, returning a value between 0 (no match) and 100 (perfect match)计算字符串1和字符串2之间的一致程度,返回0(不匹配)和100(完全匹配)之间的值

UTL_MATCH函数简介

The UTL_MATCH package facilitates matching two records. This is typically used to match names, such as two First Names or two Last Names.
译文:UTL_MATCH包有助于匹配两个记录。 这通常用于匹配名称,例如两个名或两个姓。

Edit Distance 概念

“Edit Distance”也称为“ Levenshtein距离”&