Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

H2 "runscript" command turns all table names into uppercase

Tags:

sql

mysql

init

h2

I have a sql script (it is just schema definition). The script is a modified version (getting rid of the bad characters h2 doesn't like) of a mysql dumb.

The script runs and the schema is inserted into the h2 database, but the issue is that all of the database names are in uppercase ('xyz' gets converted to 'XYZ').

I need them to stay in lowercase because my application is looking for the lowercase (and all of the tables in the mysql db are lowercase).

Why is this happening? How can I tell h2 to not do that? Is there a better way to insert schema definition into h2?

This is the INT command I'm running:

jdbc:h2:mem:~/test;INIT=runscript from '~/schema.sql'

EDIT: Just tried this on the h2 console, same thing. So this isn't some INIT issue, it is with the 'RUNSCRIPT' command.

Tried this

RUNSCRIPT FROM '~/schema.sql'
like image 546
Nacht Avatar asked Jul 08 '13 14:07

Nacht


1 Answers

Found the issue. By default, h2 has this setting set to true DATABASE_TO_UPPER. Setting that to false will save the data as expected. So in my INIT command (before it), I entered:

 jdbc:h2:mem:~/test;DATABASE_TO_UPPER=false;INIT=runscript from '~/schema.sql'

Now the tables are being inserted in the correct case

like image 182
Nacht Avatar answered Oct 17 '22 18:10

Nacht