MySQL 中的列名和表名是否区分大小写?

2021-11-20 00:00:00 mysql collation case-sensitive

如果我有一个名为 category_idCategory_Id 的列名,它们是否不同?

If I have a column names called category_id and Category_Id, are they different?

如果我有名为 categoryCategory 的表,它们是否不同?

And if I have table called category and Category, are they different?

推荐答案

在 Unix 上,表名区分大小写.在 Windows 上,它们不是.有趣,不是吗?有点像他们各自的文件系统.你认为这是巧合吗?

On Unix, table names are case sensitive. On Windows, they are not. Fun, isn't it? Kinda like their respective file systems. Do you think it's a coincidence?

换句话说,如果您计划在 Linux 机器上部署,最好也针对基于 Linux 的 MySQL 测试您的 SQL,或者在生产时为神秘的找不到表"错误做好准备.现在虚拟机很便宜.

In other words, if you are planning on deploying on a Linux machine, better test your SQL against a Linux-based MySQL too, or be prepared for mysterious "table not found" errors at prod time. VMs are cheap these days.

字段(列)名称不区分大小写.

Field (column) names are case-insensitive regardless.

我们讨论的是 MySQL 服务器 机器上的操作系统,而不是客户端.

we're talking about the operating system on the MySQL server machine, not client.

相关文章