我肯定遗漏了一些非常明显的东西,但我有这个非常基本的 MySQL 查询:
SELECT count(*) from information_schema.tables WHERE table_schema == "my_table";
但是,此查询始终返回零,即使“my_table”存在。我在这里缺少什么?
最佳答案
在特定模式(数据库)中搜索表。您必须在查询中提供 TABLE_SCHEMA
。
SELECT count(*) from information_schema.tables where table_name = 'my_table' and table_schema = 'database_name'
同时执行 SELECT * from information_schema.tables
以查看其他信息表包含的内容。
关于mysql - 计算 MySQL 表总是返回零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35941181/