A beneficio di tutti riporto una cosa magari ovvia ma che mi ha fatto dannare per parecchio tempo.
Avrete notato che sotto Windows i nomi delle tabelle di MySQL sono tutti in minuscolo vero?
Io ho l'abitudine di chiamare le tabelle con sia maiuscoli e minuscoli perche' preferisco nomi lunghi e significativi piuttosto che acronimi incomprensibili. Ad esempio, una mia tabella si puo' chiamare anagraficaUtenti, supportoLombareSedilePosteriore e cosi' via.
Per abitudine sviluppo sotto windows e quando porto i dati in una macchina Linux, i nomi delle tabelle di MySQL, essendo legati al filesystem, diventano improvvisamente rilevanti. Dunque se voi avete una tabella che sotto windows si chiama anagraficautenti e sotto linux fate una SELECT from anagraficaUtenti, la query fallisce perche' non viene trovata la tabella. Questa e' una assurdita' che si puo' risolvere con una direttiva di MySQL.
In pratica potete forzare lo stesso comportamento che c'e' sotto Linux anche sotto Windows, facendo si' che i nomi delle tabelle siano case sensitive.
Per fare questo non dovete fare altro che aggiungere un parametro alla riga di comando con la quale lanciate il daemon di MySQL, per la precisione:
lower_case_table_names
Se lanciate:
otterrete lo stesso comportamento di Linux anche sotto Windows. I valori permessi sono 0, 1, 2. Per maggiori informazioni, leggete qui: http://dev.mysql.com/doc/mysql/en/Na...nsitivity.htmlcodice:mysqld --lower_case_table_names=0
Un breve estratto:
How table and database names are stored on disk and used in MySQL is defined by the lower_case_table_names system variable, which you can set when starting mysqld. lower_case_table_names can take one of the following values:
- 0 => Table and database names are stored on disk using the lettercase specified in the CREATE TABLE or CREATE DATABASE statement. Name comparisons are case sensitive. This is the default on Unix systems. Note that if you force this to 0 with --lower-case-table-names=0 on a case-insensitive filesystem and access MyISAM tablenames using different lettercases, this may lead to index corruption.
- 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 as of MySQL 4.0.2, and to table aliases as of 4.1.1. This value is the default on Windows and Mac OS X systems.
- 2 => Table and database names are stored on disk using the lettercase specified in the CREATE TABLE or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. Note: This works only on filesystems that are not case sensitive! InnoDB table names are stored in lowercase, as for lower_case_table_names=1. Setting lower_case_table_names to 2 can be done as of MySQL 4.0.18.