阻止 MySQL table 反引号阻止跨模式查询

Stop MySQL table backticks from preventing cross schema queries

我注意到 MySQL 中的奇怪行为,只有当 {schema}.{table_name} 未在反引号 (`) 中引用时,跨模式查询才有可能。现在这是根据 MySQL 转义保留字用作表名等的技术在技术上定义的行为,但是一个功能(安全使用保留字)阻止另一个功能(跨模式查询)似乎违反直觉.有没有什么方法可以禁用它,或者我唯一的选择是在跨模式查询中不在我的表名周围使用反引号。

架构名称和 table 名称是单独的标记,应单独分隔。

https://dev.mysql.com/doc/refman/8.0/en/identifier-qualifiers.html 说:

If any components of a multiple-part name require quoting, quote them individually rather than quoting the name as a whole. For example, write `my-table`.`my-column`, not `my-table.my-column`.

这同样适用于使用架构和 tables,例如:

错误 — 尝试在当前架构中查找名称字面上为 db1.mytable 的 table。

SELECT * FROM `db1.mytable`;

RIGHT — 在架构 db1.

中使用名为 mytable 的限定 table
SELECT * FROM `db1`.`mytable`;