oracle 模糊查询不区分大小写 regexp_like

regexp_like( source_string ,pattern )

regexp_like(source_string ,pattern ,match_parameter )

  • source_string is a character expression that serves as the search value. It is commonly a character column and can be of any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB.

  • pattern is the regular expression. It is usually a text literal and can be of any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. It can contain up to 512 bytes. If the datatype of pattern is different from the datatype of source_string, Oracle converts pattern to the datatype of source_string. For a listing of the operators you can specify in pattern, please refer to Appendix C, " Oracle Regular Expression Support".

  • match_parameter is a text literal that lets you change the default matching behavior of the function. You can specify one or more of the following values for match_parameter:

    • 'i' specifies case-insensitive matching.

    • 'c' specifies case-sensitive matching.

    • 'n' allows the period (.), which is the match-any-character wildcard character, to match the newline character. If you omit this parameter, the period does not match the newline character.

    • 'm' treats the source string as multiple lines. Oracle interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, Oracle treats the source string as a single line.

source_string 是要查询匹配的字段

pattern 是正则表达式

match_parameter 匹配参数

‘i’不区分大小写

‘c’区分大小写


例如:

select A.CODE             AS arrivalStationCode,
       A.NAME             AS arrivalStationName,
       A.RAIL_BUREAU_NAME AS railReceiveBureau,
       B.RECEIVING_CODE   AS receiveUnitCode,
       B.RECEIVING_NAME   AS receiveUnitName,
       A.PROVINCE_NAME    AS province,
       B.RAILWAY_NAME     AS railwayName
  from B_PORT_STATION_INFO A, B_STATION_RECEIVING_STORAGE B
 where A.CODE = B.STATION_CODE(+) and regexp_like(A.MNEMONIC,'[N]','i')

但是如果在写sql时使用占位符
regexp_like(A.MNEMONIC,'[?]','i')
可能不会正确执行,程序可能将占位符看做正则符号。


  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值