dbTalk Databases Forums  

Case sensitivity

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Case sensitivity in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Philipp Post
 
Posts: n/a

Default Case sensitivity - 07-30-2010 , 10:51 AM






Good day,

Environment: DB2 Express-C 9.7 on Windows XP.

From what I understood by a web search, DB2 compares the tables data
always in a case sensitive way and can not be changed in this
behaviour by default. (MS SQL Server could)

Now my questions:

1) How do I best avoid invalid data in a primary key column. Say
country_code should always be upper cased. Should a CHECK constraint
be used? Are there other / better ways?

2) If I need to do a JOIN on some other (not constained) columns, what
is the best way to enforce a comparison in a case insensitive way. Say
'Netherlands' and 'netherlands' and 'NETHERLANDS' should all JOIN in
the same way. Should UCASE / LCASE put into the JOIN condition? What
about the performance then? Other options here?

Thanks and brgds

Philipp Post

Reply With Quote
  #2  
Old   
Serge Rielau
 
Posts: n/a

Default Re: Case sensitivity - 07-30-2010 , 01:19 PM






On 7/30/2010 9:21 PM, Philipp Post wrote:
Quote:
Good day,

Environment: DB2 Express-C 9.7 on Windows XP.

From what I understood by a web search, DB2 compares the tables data
always in a case sensitive way and can not be changed in this
behaviour by default. (MS SQL Server could)

Now my questions:

1) How do I best avoid invalid data in a primary key column. Say
country_code should always be upper cased. Should a CHECK constraint
be used? Are there other / better ways?

2) If I need to do a JOIN on some other (not constained) columns, what
is the best way to enforce a comparison in a case insensitive way. Say
'Netherlands' and 'netherlands' and 'NETHERLANDS' should all JOIN in
the same way. Should UCASE / LCASE put into the JOIN condition? What
about the performance then? Other options here?

Thanks and brgds

Philipp Post

Philipp, Actually you can create the database with a case insensitive
collation.
Of course that has performance implications compared to binary or system
collation.

Anyway, a CHECK constraints is the way to go for individual columns.
They are very efficient in DB2.

When you join with another non-uppercased column you would need to
uppercase that column in deed. Thsi can have negative impact on the
optimizer plan (since Db2 can't use an index anymore.
You can mitigate that by adding a generated column that pre-computes the
uppercased value.

--
Serge Rielau
SQL Architect DB2 for LUW
IBM Toronto Lab

Reply With Quote
  #3  
Old   
Philipp Post
 
Posts: n/a

Default Re: Case sensitivity - 07-31-2010 , 08:34 AM



Thanks Serge, that helps. Also I now found the right papers on this at
Developerworks.

brgds

Philipp Post

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.