设置mysql表名大小写不敏感

本文探讨了在跨平台程序设计中,MySQL的lower_case_table_names系统变量在不同操作系统上的默认值差异,及其对表名大小写敏感性的影响。在Windows上,默认值为1,使表名在存储和查找时转换为小写;在Linux上,默认值为0,保持创建时的大小写;在macOS上,默认值为2,虽保持创建时的大小写,但在查找时转换为小写。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

               

在跨平台的程序设计中要注意到mysql的一些系统变量在windows和linux上的缺省值是不同的, 比如mysql表名称的大小写变量.

在windows上lower_case_table_names变量的缺省值为1; 在linux上为0; 在mac os上为2;

该变量值的详细定义如下:

ValueMeaning
0Table 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 Mac                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.
1Table 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.
2Table 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 forlower_case_table_names=1.


如果想在linux环境中想设置表名为大小写不敏感, 那么可以通过如下的命令:

mysqld --SET-lower_case_table_names=1;

或者在mysql server的配置文件中添加配置项:

vi /etc/my.cnf

# The MySQL server[mysqld]set-variable=lower_case_table_names=1

iefreer



           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.youkuaiyun.com/jiangjunshow

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值