Case Sensitive issue of tables in different server

I am working in three different servers which are unix/windows/unix.

case-1 : In my loacl server which is unix I have one table name Country_master and its fields pk_CountryId, CountryName etc.

case-2 :In my Demo server which is window table name changed automatically to country_master.

case-3 :In my Live server which is unix table name country_master.

But in my code table name i taken is Country_master so it gives me error like this

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'markets.Country_master' doesn't exist'.

Can i have any way not to change table name in database and also in code but it takes lower case?


If you are using MySQL you can set table and column name case sensitive in my.conf by using following directive

set-variable = lower_case_table_names=1

Do not forget the restart server after update. It would be better if you use same column names in all servers


You can change the case sensitivity by setting the lower_case_table_names system variable. See here for instructions:

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


From the fine manual:

In MySQL, databases correspond to directories within the data directory. Each table within a database corresponds to at least one file within the database directory (and possibly more, depending on the storage engine). Triggers also correspond to files. Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database, table, and trigger names.

So the case sensitivity of your table names depends on the underlying file system: they will (usually) be case insensitive on Windows and OSX but case sensitive on Linux. This behavior is partially dependent on the lower_case_table_names setting:

If set to 0, table names are stored as specified and comparisons are case sensitive. If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive. If set to 2, table names are stored as given but compared in lowercase. This option also applies to database names and table aliases.

So you have various things that will affect the case sensitivity of your table names. The only sane solution (IMO) is to always use lower case table names so that you don't have to worry about it; you should also use lower case column names for consistency.

链接地址: http://www.djcxy.com/p/69214.html

上一篇: 警告:mysql

下一篇: 不同服务器中的表格区分大小写问题