> I am currently evaluating H2 DB to use one of my project.
Did you try another database before? If yes which one?
> While testing one of the requirement, I found that the column names
> read from ResultSetMeta is uppercase whereas the table columns are
> created with case sensitive.
See
http://www.h2database.com/html/grammar.html#name
"Names are not case sensitive. "
http://www.h2database.com/html/grammar.html#quotedname
Quoted names are case sensitive, and can contain spaces. There is no
maximum name length.
Two double quotes can be used to create a single double quote inside
an identifier.
> CREATE TABLE TestTable (EmpId INT,EmpName VARCHAR(50));
> select * from TestTable
> ResultSetMeatData.getColumnName(1)= > "EMPID".
You didn't use quoted identifiers when creating the table, therefore
H2 stores them as uppercase. This is according to the SQL standard.
> CREATE TABLE TestTable ("EmpId" INT,"EmpName" VARCHAR(50));
> select * from TestTable EmpId=2
> Column EMPID not found
If you use quoted identifiers when creating the table, and you use
mixed case identifiers, you also need to use quoted identifiers when
selecting: select * from TestTable where "EmpId"=2. This is also
according to the SQL standard. Your forgot WHERE.
> CREATE TABLE TestTable ("EmpId" INT,"EmpName" VARCHAR(50));
> insert into testtable ( empid , empname ) values (2,"Gerald");
You made two mistakes: you didn't use quoted in one place and not the
other; and you used double quotes instead of single quotes for the
varchar value. Try:
insert into testtable ( "EmpId", "EmpName") values (2,'Gerald');
Regards,
Thomas
> Though he is telling it is a ANSI SQL standar, it would be a very help
> if the case sensitive column support is enable by passing some
> properties on the connection URL.Something like this:
>
> jdbc:h2:<url>;CASE_SENSITIVE_COLUMN={TRUE|FALSE} .
That's an idea, but the setting would have to be stored in the
database. I wonder why you don't just want to use the SQL standard?
Regards,
Thomas
> I just want to comment on your following point which you had posted
> earlier.
>
> <!------ In fact all major DBMS (Postgres, Oracle, Firebird, DB2, SQL
> Server,
> Sybase, Ingres) behave like this. At least when it comes to quoted
> identifiers. ----->
For for completeness, I wrote before:
"
This is how the ANSI SQL standard requires the usage of (quoted)
identifiers:
Not quoted --> Case insensitive
Quoted --> Case sensitive
In fact all major DBMS (Postgres, Oracle, Firebird, DB2, SQL Server,
Sybase, Ingres) behave like this. At least when it comes to quoted
identifiers.
Some actually chose to store identifiers in lower case - which is not
standard compliant. The ANSI standard actually requires that all non-
quoted identifiers are stored in upper case.
But all adhere to the standard that quoted identifiers are case-
sensitive.
"
> This is not true, because I have created a table with case senstive
> columns in sysbase and while iterating the column names
> (ResultSetMetaData.getColumnName(1)) it returns the orginal case that
> was used at the time of table creation.
I didn't mean to say all databases return uppercase or behave exactly
the same. Actually there is quite a big difference in how databases
store and return unquoted identifiers. Only when using quoted
identifiers, almost all databases work in the same way.
Maybe a solution would be to use quoted identifiers, or do you already
do that? Could you post the code you have used so far?
Regards,
Thomas