This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Case sensitivity in table names

 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Deppends on your database. SQL Server for example can be configured to be case sensitive or not. Check the PostgreSQL docs.
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic