Oracle DB: how can I write a query ignoring case?

As I wrote in the header, I have an SQL query running on Oracle DB, let's say:

SELECT * FROM TABLE WHERE TABLE.NAME Like 'IgNoReCaSe' 

If I wanted the query to return either "IGNORECASE", "ignorecase", or a combination of them, how can this be done?

Is it possible?

+52
sql database oracle
Jun 23 '09 at 10:51
source share
8 answers

You can use ALTER SESSION statements to match case-sensitive. See this FAQ .

 alter session set NLS_COMP=ANSI; alter session set NLS_SORT=BINARY_CI; 
+36
Jun 23 '09 at 11:29
source share
β€” -
 Select * from table where upper(table.name) like upper('IgNoreCaSe'); 

Alternatively, replace the lower upper.

+115
Jun 23 '09 at 10:56
source share

You can use either the bottom or top function on both sides of the where clause

+28
Jun 23 '09 at 10:53
source share

You can also use regular expressions:

 SELECT * FROM TABLE WHERE REGEXP_LIKE (TABLE.NAME,'IgNoReCaSe','i'); 
+12
Jun 23 '09 at 15:49
source share

You can use the upper () function in your query, and to improve performance you can use the functional base index

  CREATE INDEX upper_index_name ON table(upper(name)) 
+7
Jun 23 '09 at 11:23
source share

You can convert both values ​​to upper or lower case using the upper or lower functions:

 Select * from table where upper(table.name) like upper('IgNoreCaSe') or lower(table.name) like lower('IgNoreCaSe'); 
+4
May 22 '14 at 17:28
source share

... also converts to the top or bottom of the query:

 tableName:= UPPER(someValue || '%'); 

...

 Select * from table where upper(table.name) like tableName 
+3
Jun 23 '09 at 11:38
source share

In addition, do not forget that you need to do data in tables? You can insert rows already in lowercase (or convert existing database rows to lowercase) and do this from the very beginning.

0
Jun 23 '09 at 22:32
source share



All Articles