Unixä¸ã®MYSQLã§å¤§æåã§Tableãä½æå¾ã«lower_case_table_names=1ã¨ããå ´åã«ã大æåã®Tableãæ¤ç´¢ã§ããªãã
æ¦è¦
OSãUnixãã¤å¤§æåã§Tableãä½æå¾ã«å¤§æåå°æåãåºå¥ããªãã¨ããå ´åã«ã大æåã®Tableãæ¤ç´¢ã§ããªããªãã¾ããï¼Redhatã¨CentOSã§ç¾è±¡ã確èªãWindows7ã§çºçããªããã¨ã確èªï¼
詳細
MySQLã§ã¯å¤§æåå°æåã®åºå¥ãè¡ããã©ããã¯ãlower_case_table_namesãã®è¨å®ãè¡ããã¨ã§å¤æ´ãå¯è½ã§ãã
MySQLã§ã®ãã¼ãã«ã¨ãã¼ã¿ãã¼ã¹åã®ä¿åæ¹æ³ã¯lower_case_table_namesã·ã¹ãã å¤æ°ã«å½±é¿ããã¾ããããã¯mysqldèµ·åæã«è¨å®ã§ãã¾ãã lower_case_table_namesã¯ä»¥ä¸ã®ãã¼ãã«ã«ç¤ºãããå¤ãã¨ãå¾ã¾ããUnixã§ã¯ãlower_case_table_namesã®ããã©ã«ãå¤ã¯ 0ã§ãWindowsã§ã¯1ãMac OS Xã§ã¯2ã¨ãªãã¾ãã
http://dev.mysql.com/doc/refman/5.1/ja/identifier-case-sensitivity.html
ä¸è¨ã®éããUnixã®ããã©ã«ãå¤ã¯0ã§å¤§æåã¨å°æåãåºå¥ãã¾ãã
mysql> show variables where variable_name='lower_case_table_names'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_table_names | 0 | +------------------------+-------+ 1 row in set (0.00 sec) mysql> show tables; Empty set (0.00 sec) mysql> create table HOGE(HUGA VARCHAR(10)); Query OK, 0 rows affected (0.01 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | HOGE | +----------------+ 1 row in set (0.00 sec) mysql> insert into HOGE(HUGA) value ('PIYO'); Query OK, 1 row affected (0.00 sec) mysql> select * from HOGE; +------+ | HUGA | +------+ | PIYO | +------+ 1 row in set (0.00 sec) mysql> select * from hoge; ERROR 1146 (42S02): Table 'test.hoge' doesn't exist
ãã®ããã«ãHOGEããã¼ãã«ãåå¨ããç¶æ
ã§ã大æåå°æåãåºå¥ããªãè¨å®ã«å¤æ´ãã¦ã¿ã¾ãã
å¤æ´ããããã«ã¯my.cnfã«ãlower_case_table_names=1ããå ãã¾ãã
ã¡ãªã¿ã«my.cnfã®åªå
é ä½ã¯âã®éãã
Linuxç³»ã®MySQLã§ã¯ã
http://yoku0825.blogspot.jp/2012/11/mycnf.html
/etc/my.cnf -> /etc/mysql/my.cnf -> SYSCONFDIR/my.cnf -> $MYSQL_HOME/my.cnf -> defaults-extra-fileã§æå®ããããã¡ã¤ã« -> $HOME/.my.cnf -> ç´æ¥æ¸¡ãããªãã·ã§ã³
ã®é çªã§èªã¿è¾¼ã¾ããã
ã§ããã®ç¶æ ã§ãHOGEããã¼ãã«ãæ¤ç´¢ãã¦ã¿ã¾ãã
mysql> show variables where variable_name='lower_case_table_names'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_table_names | 1 | +------------------------+-------+ 1 row in set (0.00 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | HOGE | +----------------+ 1 row in set (0.00 sec) mysql> select * from HOGE; ERROR 1146 (42S02): Table 'test.hoge' doesn't exist mysql> select * from hoge; ERROR 1146 (42S02): Table 'test.hoge' doesn't exist
ãã®ããã«å¤§æåã§ãå°æåã§ãåå¾ã§ããªããªãã¾ãã
ãlower_case_table_names=1ãã®èª¬æã¨ãã¦ã¯âã¨ããã¾ãããã«ãã¯ã¢ããæã£ã¦ã©ããããã¨ã§ããï¼ï¼
ãã¼ãã«åã¯ãã£ã¹ã¯ä¸ã«å°æåã§è¨æ¶ãããååæ¯è¼ã§ã¯å¤§æåå°æåã¯åºå¥ããã¾ãããMySQLã§ã¯ãä¿ç®¡ããã³ã«ãã¯ã¢ããæã«å ¨ã¦ã®ãã¼ãã«åãå°æåã«å¤æããã¾ãããã®ãªãã·ã§ã³ã¯ãã¼ã¿ãã¼ã¹åããã¼ãã«ã¨ã¤ãªã¢ã¹ã«ãé©ç¨ããã¾ãã
http://dev.mysql.com/doc/refman/5.1/ja/identifier-case-sensitivity.html
å°ãWindows7ã§åæé ã§å®æ½ãã¾ãããããHOGEãã§ããhogeãã§ãåå¾å¯è½ã§ããã
åé¿ç
åé¿çã¨ãã¦ã¯ãlower_case_table_names=0ãã®ç¶æ
ã§Tableåãå°æåã«å¤æ´ããã¨ããæ¹æ³ããã¿ã¤ããã¾ããã§ããã
ä½ãä»ã«æ¹æ³ãããã¾ãããæãã¦ä¸ããã
mysql> show variables where variable_name='lower_case_table_names'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_table_names | 0 | +------------------------+-------+ 1 row in set (0.00 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | HOGE | +----------------+ 1 row in set (0.00 sec) mysql> rename table HOGE to hoge; Query OK, 0 rows affected (0.00 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | hoge | +----------------+ 1 row in set (0.00 sec)
ã¡ãªã¿ã«ãå°æåã®viewãä½æãããã©ããã¨è©¦ãã¦ã¿ã¾ãããããã¯ãåºå¥ãã¤ããªãããã§ã¨ã©ã¼ãåºã¾ããã
mysql> show variables where variable_name='lower_case_table_names'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_table_names | 0 | +------------------------+-------+ 1 row in set (0.00 sec) mysql> create view hoge as select * from HOGE; Query OK, 0 rows affected (0.00 sec) mysql> select * from hoge; +------+ | HUGA | +------+ | PIYO | +------+ 1 row in set (0.00 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | HOGE | | hoge | +----------------+ 2 rows in set (0.00 sec)
my.cnfã«ãlower_case_table_names=1ããå ãã¦åèµ·åã
mysql> show variables where variable_name='lower_case_table_names'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_table_names | 1 | +------------------------+-------+ 1 row in set (0.00 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | HOGE | | hoge | +----------------+ 2 rows in set (0.01 sec) mysql> select * from hoge; ERROR 1462 (HY000): `test`.`hoge` contains view recursion mysql> select * from HOGE; ERROR 1462 (HY000): `test`.`hoge` contains view recursion