mysql 表名大小写敏感处理 lower_case_table_names

到mysql数据库下查询表时,差点没被表名的大小写搞死。
到官网查看文档,可以通过参数控制

# vi /etc/my.cnf
[mysqld]
lower_case_table_names=1  

官网的描述如下

lower_case_table_names can take the values shown in the following table. This variable does not affect case sensitivity of trigger identifiers. 
On Unix, the default value of lower_case_table_names is 0. 
On Windows, the default value is 1. 
On 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 TABLE or CREATE DATABASE statement. 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 OS X). If you force this variable to 0 with --lower-case-table-names=0 on a case-insensitive file system and access MyISAM tablenames 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 TABLE or CREATE DATABASE statement, 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! InnoDB table names are stored in lowercase, as for lower_case_table_names=1.

0:使用 CREATE TABLE 或 CREATE DATABASE 语句中指定的字母将表和数据库名称存储在磁盘上。名称比较区分大小写。如果在具有不区分大小写的文件名(如Windows或OSX)的系统上运行MySQL,则不应将此变量设置为0。如果在不区分大小写的文件系统中强制此变量为-小写表名=0,并使用不同的字母案例访问MyISAM表名,则可能会导致索引损坏。

1:表名以小写形式存储在磁盘上,名称比较不区分大小写.MySQL在存储和查找时将所有表名转换为小写。此行为也适用于数据库名称表别名

2:使用 CREATE TABLE 或 CREATE DATABASE 语句中指定的字母将表和数据库名称存储在磁盘上,但MySQL**在查找时将它们转换为小写。名称比较不区分大小写**。这只在不区分大小写的文件系统上工作!InnoDB表名以小写形式存储,对于LOWER_CASE_TABLE_NAMES=1。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据库人生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值