php - 我可以安全地依赖 mysql 中的列名大小写吗?

标签 php mysql case-sensitive

我想使用驼峰式命名我的 mysql 表列名称,并使用相同的驼峰式名称从这些 mysql 表创建 php 类。我将自动生成这些 php 类。我想知道无论我在哪个平台上运行我的应用程序,我是否都可以依赖列名大小写。因此,例如,如果我将一个列名称命名为“FirstName”,我是否会遇到从数据库中读取列名称会产生“firstname”或类似名称的情况?

最佳答案

简短的回答是否定的。

长话短说,MySQL 中某些事物的大小写敏感性取决于底层操作系统。 (Unix 是敏感的)

这里是对 MySQL documentation. 中问题的引用

Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database and table names. This means database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix. One notable exception is Mac OS X, which is Unix-based but uses a default file system type (HFS+) that is not case sensitive.

还特别来自关于列名的文档:

Column, index, and stored routine names are not case sensitive on any platform, nor are column aliases. Trigger names are case sensitive, which differs from standard SQL.

关于php - 我可以安全地依赖 mysql 中的列名大小写吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12045806/

相关文章:

Mysql join 多表分层数据

mysql - 轨道 3 : Finding records with datetime 3 days from today

regex - 在 Perl 中覆盖区分大小写的正则表达式

php - 为什么 css 不影响我的 PHP 页面?

php - 错误 #1136 但上传备份的 WordPress 数据库时,列似乎与值匹配

mysql - hibernate 查询错误

.net正则表达式性能考虑: Use (partial or global) case-insensitive matching or explicit character groups?

java - 反向传播 - 字符识别 - 求一个例子

php - 我可以像这样重写我的 URL,这是个好主意吗?

javascript - 如何区分字母的大小写?