| Author |
DB2 - case sensitive or not
|
Mike Yu
Ranch Hand
Joined: Nov 17, 2001
Posts: 175
|
|
Hi, When I do a search in a DB2 database table using a SQL string, for example, select * from table1 where column1 like 'Abc'. Does the select condition in the where clause (e.g., 'Abc' in the above example) case sensitive or not? If is case sensitive, then how can I select everything from the table containing abc regardless the case of the characters?
|
Thanks,<br />Mike
|
 |
Jamie Robertson
Ranch Hand
Joined: Jul 09, 2001
Posts: 1879
|
|
to avoid case sensitivity you can use a DB2 procedure in your query (example is using Oracle) like: "select * from table where UPPER( column1 ) like UPPER( '" + string_val + "') "); *note: UPPER is the Oracle procedure for upper case conversion, not sure what the equivalent DB2 procedure is You can find out if the column is case sensitive by doing some test queries. Jamie
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
You can follow Jamie's example and use UCASE instead of UPPER. UCASE is the DB2 equivalent of that function. [ August 07, 2002: Message edited by: Bosun Bello ]
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
Mike Yu
Ranch Hand
Joined: Nov 17, 2001
Posts: 175
|
|
HI Jamie and Bosun, Thank you for your help. One further question: When using select * from table1 where column1 = 'abc', the select is NOT case sensitive. Is it right?
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
Mike, it is not case sensitive. Why don't you try it and see what happens?
|
 |
Mike Yu
Ranch Hand
Joined: Nov 17, 2001
Posts: 175
|
|
Hi Bosun, Thank you again. I really tried. I just wanted to make sure that it is 100% right.
|
 |
Paul Misoni
Greenhorn
Joined: Jan 02, 2001
Posts: 16
|
|
You only have to be concerned about the DATA regarding case. For reserved words and metadata it doesn't matter ('cause DB2 is going to treat those as uppercase anyways). (Just throwing in my two cents worth)
|
 |
 |
|
|
subject: DB2 - case sensitive or not
|
|
|