Pergunta

I'm converting a database from H2 to MySQL, and the way H2 exports its tables they are all named IN_UPPERCASE_CHARACTERS. Does collation only apply do the data and am I stuck manually replacing table names?

Foi útil?

Solução

MySQL collations apply only to contents of columns in the database. They are not a factor in your problem.

Column names, index names, etc, are all case-insensitive.

On Windows and Mac HFS, table names, like file names, are case-insensitive. On Linux / BSD / Unix, they, like file names, are case sensitive.

There are lots of things you can do to monkey around with all this. See here.

http://dev.mysql.com/doc/refman/5.6/en/identifier-case-sensitivity.html

If your MySQL database runs on a Windows (or Mac HFS) platform, you probably should do nothing. If it's on a *nix box, you might consider renaming the tables so they have the same case as your query code.

 RENAME `TABLENAME` TO `tablename`

Or, you can consider setting lower_case_table_names=1, renaming all your tables so they have lowercase names, and going from there. That probably gives you the most resilient coding environment to use your database: it will make your table names in your code case-insensitive. Of course if you have two different tables named tablecase and TABLECASE this won't work.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top