H2 “runscript” command turns all table names into uppercase

旧时模样 提交于 2019-12-05 17:24:42

问题


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'

回答1:


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




回答2:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!