File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Case sensitivity in table names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Case sensitivity in table names" Watch "Case sensitivity in table names" New topic

Case sensitivity in table names

Marco Ehrentreich
best scout

Joined: Mar 07, 2007
Posts: 1294


i would like to know if it is possible to use case sensitive table names in an SQL query without using escaped quotes like in this query string "SELECT * FROM \"TableName\"" for example. Is there way to force the driver or query statement to recognize TabelName in mixed case without quoting? It's no big deal using quotes but it's simply annoying especially if you can't change the table names in the database itself any more.

I'm using a PostgreSQL JDBC driver 8.2 and i already found a lot of information on case sensitivity but there was no clear conclusion concerning case sensitivity in TABLE NAMES.


Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Deppends on your database. SQL Server for example can be configured to be case sensitive or not. Check the PostgreSQL docs.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Marco Ehrentreich
best scout

Joined: Mar 07, 2007
Posts: 1294

Ok, i see this problem is partly depending on the underlying database. And i've already searched the postgresql documentation for hints on how to avoid the quotes for identifier names. I just found the following statement: "SQL is case insensitive about key words and identifiers, except when identifiers are double-quoted to preserve the case..."

There are many options and parameters to set directly on the database server for incoming client connections. For example the default encoding. But i didn't find any possibility to tell the database server to use case sensitive identifier names by default.

So obviously identifier names are case insensitive by default which means at least for the JDBC driver i am using that a table named TableName will become tablename when not enclosed in backslashes and double-quotes.

And what i really wanted to know is if there is kind of a mechanism in the JDBC API or drivers to "automatically" quote identifiers in query statements and make it case sensitive this way without inserting all those annoying backslashes and double-quotes. If not then i surely will have to get used to it.
I agree. Here's the link:
subject: Case sensitivity in table names
It's not a secret anymore!