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/

相关文章:

php - 在电子邮件通知上显示自定义结帐账单字段

php - Laravel 5.2 [PDOException] SQLSTATE[42000] - 创建两个 auto_increment 主键字段

mysql - 我在插入选择时收到不正确的日期值

php - 从数据库中选择 WHERE 一些参数等于字符串 var 的一部分

php - 将 mysql_fetch_object() 的结果传递给函数不起作用

php - 使用 PDO 获取单个返回值

mysql - MySQL中的表名区分大小写吗?

mysql - 如何强制区分大小写的表名?

php - Switch 不适用于数字比较案例

vb.net - VB真的不区分大小写吗?