1

In my DB2, I created database with name 'SAMPLE'. And, while connect with Razor DB2 client, it can connect to 'SAMPLE' database without case-sensitive.

For example,

jdbc:db2://localhost:50000/sAmple

jdbc:db2://localhost:50000/Sample

jdbc:db2://localhost:50000/saMple

jdbc:db2://localhost:50000/SAMPLE

They all can connect to DB2. But when I take results with them, only SAMPLE database can show results. I want to know that how I can connect to DB2 with only 'SAMPLE' database name with case-sensitive.

4
  • Could you explain what you mean by "when I take results with them, only SAMPLE database can show results"?
    – mustaccio
    Oct 9, 2014 at 2:39
  • "select * from TABLE(SNAP_GET_BP(CAST(NULL as varchar(255)), -1)) where db_name='SAMPLE'" can show results.
    – Eido Shack
    Oct 9, 2014 at 5:47
  • Instead "select * from TABLE(SNAP_GET_BP(CAST(NULL as varchar(255)), -1)) where db_name='sample'" can not show results. But It can connect successfully to SAMPLE database.
    – Eido Shack
    Oct 9, 2014 at 5:48
  • Either transform the parameter for db_name before handing it over to the sql, or use upper or ucase function as in where db_name=upper('sample') Oct 9, 2014 at 10:19

1 Answer 1

3

DB2 databases are not case sensitive SAMPlE = sample = SAMple. However:

  • Some tools need the upper case in order to work. Probably, they take into account the instance directory (db2 list db directory)
  • The database name is changed to upper case for internal identification and it is stored like this in the database catalog. And any function that use the database name should be in upper case.

This behavior is similar to a table. For example, EMPLOYEE = employee, but the table is stored as EMPLOYEE in the database catalog. However, you can force the name in lower case by surrounding by quotes, like "employee", but this is considered as a bad practice. In the other hand, database name does not keep the case is surrounded by quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.