【问题标题】:Check all tables, columns and types in redshift检查 redshift 中的所有表、列和类型
【发布时间】:2018-10-11 19:41:13
【问题描述】:

您好,我正在尝试为我所有的 sachems 查找表、列和类型,而不仅仅是 redshift 中的公共对象

【问题讨论】:

    标签: amazon-redshift


    【解决方案1】:

    看看System Tables Reference - Amazon Redshift

    例如:PG_TABLE_DEF 存储有关表列的信息:

    select "column", type, encoding, distkey, sortkey, "notnull" 
    from pg_table_def
    where tablename = 'lineorder_compound' 
    and sortkey <> 0;
    
    column       | type    | encoding | distkey | sortkey | notnull
    -------------+---------+----------+---------+---------+--------
    lo_orderkey  | integer | delta32k | false   |       1 | true   
    lo_custkey   | integer | none     | false   |       2 | true   
    lo_partkey   | integer | none     | true    |       3 | true   
    lo_suppkey   | integer | delta32k | false   |       4 | true   
    lo_orderdate | integer | delta    | false   |       5 | true   
    (5 rows)
    

    【讨论】:

    • Betsy 可能会这样做,但只看到公共架构,她需要先运行 set search_path to public, schema1, schema2, etc. 才能看到 pg_table_def 输出中的其他架构
    【解决方案2】:

    @John 我查看了系统表引用,主要问题是它只能查看基表中的表和列。

    我只需要提取从这些表中创建的视图,并且只显示视图中的列而不是它们所基于的基表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-04
      • 1970-01-01
      • 1970-01-01
      • 2019-02-05
      • 2021-12-01
      • 2023-01-18
      • 1970-01-01
      • 2012-10-26
      相关资源
      最近更新 更多