Skip to content
Advertisement

is “SELECT fieldname, fieldName FROM MY_TABLE;” ever valid for any SQL database?

Do any SQL databases have case-sensitive naming for field names?

What I mean is, in Java you can have two variables …

Are there any SQL databases support that so …

… would return two different columns?

I’m asking because I’m building a database utility that has to work for MySQL, H2, PostgreSQL, Oracle, and SQL Server, so I need to know how they all work for a bit of code I’m writing.

Advertisement

Answer

By the SQL standard, SQL identifiers are case-insensitive. So, without escape characters, these refer to the same column:

However, you can escape the names and they become distinguishable. The standard SQL escape character is ":

But some databases don’t support this and have their own.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement