• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1157
  • Last Modified:

What is the difference between LIKE clause of oracle and using regexp?

What is the difference between LIKE clause of oracle and using  regexp?
Nusrat Nuriyev
Nusrat Nuriyev
1 Solution
Terry WoodsIT GuruCommented:
I can't give details on the complexities of how it will affect performance, but regular expressions (using REGEXP_LIKE) allow for much more complicated patterns than what LIKE does. Some details on what can be used in a REGEXP_LIKE pattern are here.

For example, a regular expression can match a letter from a to m, followed by 3 or 4 numbers between 2 and 7:

Open in new window

This could not be done with a single use of LIKE.
slightwv (䄆 Netminder) Commented:
Agree with the above post.  LIKE only uses wildcard operators, '%' and '_'.  Regular expressions are EXTREMLY powerful and can match just about anything you can dream up.

Of course, that comes with a price.  Regular expression operations can be very expensive.

LIKE can also use an index if there are no left sided wildcards.
as noted above, you can do more with regular expressions

however, regexp operations are expensive (in terms of cpu and time) and can not, by default, be indexed.

LIKE clauses on leading values can be indexed - for example   my_column like 'ABC%'  can use an index but
my_column LIKE '%ABC' can not

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now