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'
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
Another option is to wrap table/column names in double quotes to preserve casing.
E.g. create table "products"
instead of create table products
来源:https://stackoverflow.com/questions/17529384/h2-runscript-command-turns-all-table-names-into-uppercase