jpa在mysql中自动创建重复表,只是大小写不同
2014-10-16 10:28
274 查看
jpa在mysql中自动创建重复表,只是大小写不同
可通过加入环境变量解决 lower_case_table_names
参考资料: http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html http://www.alberton.info/dbms_identifiers_and_case_sensitivity.html
However, this same statement is permitted on Windows. To avoid problems caused by such differences, it is best to adopt a consistent convention, such as always creating and referring to databases and tables using lowercase names. This convention is recommended
for maximum portability and ease of use.
How table and database names are stored on disk and used in MySQL is affected by the
variable, which you can set when starting mysqld.
take the values shown in the following table. On Unix, the default value of
0. On Windows the default value is 1. On Mac OS X, the default value is 2.
Since MySQL stores each table into a file with the same name in the file system, we can
expect it to behave differently depending on the OS where it's installed.
On Windows:
On Unix/Linux:
Some interesting observations: on Windows, the table name is lowercased if unquoted, while on *nix the case is preserved. That's because of the default value of thelower_case_table_names system
variable, which is different on the two systems.
In all the platforms, the case in the field names is preserved, but no two column
可通过加入环境变量解决 lower_case_table_names
参考资料: http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html http://www.alberton.info/dbms_identifiers_and_case_sensitivity.html
However, this same statement is permitted on Windows. To avoid problems caused by such differences, it is best to adopt a consistent convention, such as always creating and referring to databases and tables using lowercase names. This convention is recommended
for maximum portability and ease of use.
How table and database names are stored on disk and used in MySQL is affected by the
lower_case_table_namessystem
variable, which you can set when starting mysqld.
lower_case_table_namescan
take the values shown in the following table. On Unix, the default value of
lower_case_table_namesis
0. On Windows the default value is 1. On Mac OS X, the default value is 2.
Value | Meaning |
---|---|
0 | Table and database names are stored on disk using the lettercase specified in the CREATE TABLEor CREATE DATABASEstatement. Name comparisons are case sensitive. You should not set this variable to 0 if you are running MySQL on a system that has case-insensitive file names (such as Windows or Mac OS X). If you force this variable to 0 with --lower-case-table-names=0on a case-insensitive file system and access MyISAMtablenames using different lettercases, index corruption may result. |
1 | Table names are stored in lowercase on disk and name comparisons are not case sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases. |
2 | Table and database names are stored on disk using the lettercase specified in the CREATE TABLEor CREATE DATABASEstatement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. This works only on file systems that are not case sensitive! InnoDBtable names are stored in lowercase, as for lower_case_table_names=1. |
MySQL
Since MySQL stores each table into a file with the same name in the file system, we canexpect it to behave differently depending on the OS where it's installed.
On Windows:
-- test table names and case sensitivity CREATE TABLE TEST_CASE (id INTEGER); --ok, test_case table created CREATE TABLE `Test_Case` (id INTEGER); --fails: already exists CREATE TABLE `test_case` (id INTEGER); --fails: already exists CREATE TABLE `TEST_CASE` (id INTEGER); --fails: already exists ALTER TABLE TEST_CASE ADD TeSt INTEGER; --ok, TeSt field created ALTER TABLE TEST_CASE ADD `TeSt` INTEGER; --fails: already exists ALTER TABLE TEST_CASE ADD `test` INTEGER; --fails: already exists ALTER TABLE TEST_CASE ADD `TEST` INTEGER; --fails: already exists INSERT INTO test_case (id) VALUES (1); --record inserted into test_case table INSERT INTO `test_case` (id) VALUES (1); --record inserted into test_case table INSERT INTO `Test_Case` (id) VALUES (1); --record inserted into test_case table INSERT INTO `TEST_CASE` (id) VALUES (1); --record inserted into test_case table INSERT INTO `TEST_case` (id) VALUES (1); --record inserted into test_case table
On Unix/Linux:
-- test table names and case sensitivity CREATE TABLE Test_Case (id INTEGER); --ok, Test_Case created CREATE TABLE `Test_Case` (id INTEGER); --fails: already exists CREATE TABLE `test_case` (id INTEGER); --ok, test_case created CREATE TABLE `TEST_CASE` (id INTEGER); --ok, TEST_CASE created ALTER TABLE TEST_CASE ADD TeSt INTEGER; --ok, TeSt field created ALTER TABLE TEST_CASE ADD `TeSt` INTEGER; --fails: already exists ALTER TABLE TEST_CASE ADD `test` INTEGER; --fails: already exists ALTER TABLE TEST_CASE ADD `TEST` INTEGER; --fails: already exists INSERT INTO Test_Case (id) VALUES (1); --record inserted into Test_Case table INSERT INTO `test_case` (id) VALUES (1); --record inserted into test_case table INSERT INTO `Test_Case` (id) VALUES (1); --record inserted into Test_Case table INSERT INTO `TEST_CASE` (id) VALUES (1); --record inserted into TEST_CASE table INSERT INTO `TEST_case` (id) VALUES (1); --fails: TEST_case table doesn't exists
Some interesting observations: on Windows, the table name is lowercased if unquoted, while on *nix the case is preserved. That's because of the default value of thelower_case_table_names system
variable, which is different on the two systems.
In all the platforms, the case in the field names is preserved, but no two column
相关文章推荐
- 如何在MySQL&Oracle下创建自动递增字段
- 根据所创建Item的title自动实现分配到不同的folder下
- python自动创建mysql的从库脚本
- mysql给创建的外键自动建立索引吗?
- mysql创建和授权用户+配置文件位置+大小写敏感问题
- 在Oracle、MySQL、MS SQL Server中创建自动增长字段
- mysql及创建不同端口实例(方法一)
- 完美实现tabsheet中融合窗体,不重复创建,并自动切换到已经创建的sheet
- mysql利用创建临时表方法去除数据表中重复值
- 【ASP.NET】如何使用类创建公共函数,在不同ASP.NET页面间重复调用
- [轉]mysql 自动增长字段创建
- mysql5和mysql5.5创建内存表的不同
- jPA自动创建数据库表的一些配置
- Ubuntu下Mysql 安装 创建数据库 创建表 指定字符集 自动增长
- MyBatis 3 自动生成 主键 针对不同的数据库(oracle/sqlserver/mysql)
- 在Mysql中创建自动增加的主键
- 使用hibernate自动在MYSQL中创建表,极其简单,改下配置文件。
- MySql不同版本对表名大小写敏感!
- MySql 数据库查询区分大小写(创建数据库时)
- 在COM接口中不要使用同时出现只是大小写不同的名字作为属性名、函数名或者参数名