Skip to content
Advertisement

How to make WHERE clause case insensitive in oracle sql database?

I need to fetch both “red” and “RED”.

For example: I need to use both upper and lower in same statement.

How can I do this?

Advertisement

Answer

You could use case insensitive parameter at session 'NLS_SORT=BINARY_CI'. There are two parameters at session level:

  • NLS_COMP
  • NLS_SORT

Let’s see a demo:

Normal scenario:

Case insensitive approach:

One more example:

To improve the performance, you could also create a case insensitive INDEX.

For example:

Now, there are ways to improve performance of above transaction. Please read Oracle – Case Insensitive Sorts & Compares

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement