【问题标题】:AWS athena SQL query on information_schema is failing关于 information_schema 的 AWS athena SQL 查询失败
【发布时间】:2018-11-18 02:10:54
【问题描述】:

我正在尝试通过运行 SQL 查询从 AWS athena 获取元数据:

SELECT table_catalog, table_schema, table_name FROM information_schema.tables
WHERE table_schema = 'information_schema'

当我遇到错误时:

找不到数据库信息架构。请检查您的查询。

在没有 WHERE 子句或其他一些条件的情况下,查询运行良好。我错过了什么吗?

【问题讨论】:

  • 您是否发现了一些参考资料表明这应该是可能的,或者参考了information_schema
  • @JohnRotenstein:正如我所说,我可以在没有 WHERE 子句的情况下运行查询。当我运行它时,对于元数据,我将 table_schema 视为“information_schema”。我不确定为什么它的字符串值在 where 条件下被混淆为数据库......
  • 这是一个较老的问题,但我觉得我应该向稍后阅读此内容的任何人指出,问题是 information_schema 视图包含有关表和视图的元数据,但不包含有关 自身的任何信息,所以FROM information_schema.tables WHERE table_schema = 'information_schema' 是无意义的。

标签: sql amazon-web-services amazon-athena information-schema


【解决方案1】:

尝试给出完整的列路径,例如information_schema.tables.table_schema

当您查询不同的架构时,最好提供列名的完整路径。

所以您的查询将如下所示:

SELECT table_catalog, table_schema, table_name FROM information_schema.tables WHERE information_schema.tables.table_schema = 'information_schema'

【讨论】:

  • 不能解决问题
猜你喜欢
  • 1970-01-01
  • 2021-11-02
  • 2021-07-26
  • 2017-09-10
  • 2021-06-07
  • 2020-09-12
  • 1970-01-01
  • 2019-09-16
  • 1970-01-01
相关资源
最近更新 更多