【问题标题】:Is there any way to display all columns and tables in a schema in Presto?有没有办法在 Presto 的模式中显示所有列和表?
【发布时间】:2019-12-23 23:04:47
【问题描述】:

我一直在努力寻找 Presto 模式中的表和列,如下所示在经典 PL/SQL 中:“select column_name, table_name from all_tab_columns?” 在 presto doc 中没有找到任何指向这个的东西。 您可以显示columns in a tabletables in a schema,但不能显示架构中具有各自列的所有表。 一个用例是查找包含所需列名的表: “从 all_tab_columns 中选择 column_name、table_name,其中 column_name 像 '%something_potentially_useful%'” similar post 正在回答如何查看 information_schema 中的所有表和模式,但不幸的是 information_schema 不包含 column_name 作为描述符。

谢谢你!

【问题讨论】:

    标签: sql presto


    【解决方案1】:

    information_schema.columns 包含所有可用信息:

    SELECT * FROM <catalog>.information_schema.columns
    

    从 Presto 327 开始,information_schema.columns 表具有以下列:

    presto:default> DESCRIBE tpch.information_schema.columns;
          Column      |  Type   | Extra | Comment
    ------------------+---------+-------+---------
     table_catalog    | varchar |       |
     table_schema     | varchar |       |
     table_name       | varchar |       |
     column_name      | varchar |       |
     ordinal_position | bigint  |       |
     column_default   | varchar |       |
     is_nullable      | varchar |       |
     data_type        | varchar |       |
     comment          | varchar |       |
     extra_info       | varchar |       |
    (10 rows)
    

    【讨论】:

      猜你喜欢
      • 2017-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-14
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多