表名大小写由参数 lower_case_table_names 控制,参数类型为 布尔值,0表示不忽略大小写(即区分大小写), 1为忽略大小写(即不区分大小写),默认为0 即区分大小写。
如下测试:
当lower_case_table_names 设置为0时,person表和PERSON表结果不相同。
[root@mysql.sock][xhy]>>show variables like 'lower_case_table_names';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_table_names | 0 |
+------------------------+-------+
[root@mysql.sock][xhy]>>select * from person where last_name='lee';
+----+------------+-----------+------+------------+
| id | first_name | last_name | sex | birth |
+----+------------+-----------+------+------------+
| 4 | Hale | Lee | M | 1988-09-10 |
| 30 | Hale | Lee | M | 1988-09-10 |
| 37 | Hale | Lee | M | 1988-09-10 |
| 41 | Hale | Lee | M | 1988-09-10 |
+----+------------+-----------+------+------------+
4 rows in set (0.00 sec)
--如下将表名设置为大写,则提示该表不存在
[root@mysql.sock][xhy]>>select * from PERSON;
ERROR 1146 (42S02): Table 'xhy.PERSON' doesn't exist
--将 lower_case_table_names设置为1 ,注意lower_case_table_names参数为只读参数,需要在配置文件修改配置,重启生效。
[root@mysql.sock][(none)]>>show variables like 'lower_case%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | OFF |
| lower_case_table_names | 1 |
+------------------------+-------+
2 rows in set (0.00 sec)
[root@mysql.sock][(none)]>>use xhy;
Database changed
[root@mysql.sock][xhy]>>select * from person;
+----+------------+-----------+------+------------+