0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Oracleで正規表現検索

Last updated at Posted at 2022-12-05

やり方

SELECT * 
FROM テーブル名
WHERE REGEXP_LIKE(カラム名, '正規表現パターン')

空文字に注意

下記SQLの場合『自己紹介』カラムの 値が空文字のレコード は結果に 上がってきません

SELECT * 
FROM 従業員
WHERE NOT REGEXP_LIKE(自己紹介, '^私の戦闘力は[0-9]{8}です')

「値が空文字のレコードは正規表現にマッチしないから、検索結果に上がってくるだろう」
と思いこみで作らないように注意。

Oracleは『空文字をNULLとして扱う』という動作になっているので、値がNULLの場合も同様。

バージョン

Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?