*
The moose likes JDBC 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Case sensitivity in table names" Watch "Case sensitivity in table names" New topic
Author

Case sensitivity in table names

Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Hi,

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.

Thanks.

Marco
Paul Sturrock
Bartender

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
Bartender

Joined: Mar 07, 2007
Posts: 1280

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: http://aspose.com/file-tools
 
subject: Case sensitivity in table names
 
Similar Threads
Statement.executeQuery fails --RESOLVED--
case insensitive search
DB2 - case sensitive or not
Can't access Oracle Schema for query
case sensitive sql statement for username and password