oracle查詢不含括號及不含指定字符的方法

字號:


    這篇文章主要介紹了oracle查詢不含括號及不含指定字符的方法,需要的朋友可以參考下。
    oracle查詢不含括號不含指定字符的記錄方法如下:
    with tmp_t as(
    select 1 as id,'測試4321_cs' as name from dual union all
    select 2,'測試 1200(測試版)' from dual union all
    select 3,'測試123(測試版)' from dual union all
    select 4,'測試 1212(d2)' from dual union all
    select 5,'測試 1212(d2)測試版' from dual union all
    select 6,'測試 123' from dual)
    select *
    from tmp_t
    where instr(name, '_cs') = 0
    and regexp_instr(name, '(.*)') = 0
    and regexp_instr(name, '\(.*\)') = 0
    結果為:
    其中regexp_instr為oracle支持的正則表達式函數(shù),其功能與instr相似。此處匹配了含有括號()和()的記錄。