从架构中获取表

时间:2018-02-09 11:56:04

标签: amazon-redshift

我有一个名为dev的数据库。在其中我有名为test_spect的模式。该模式由一些表组成。 test_spect不公开。如何从test_spect获取表名及其数据。我跑的时候

\dt test_spect.*

它说

No matching relations found.

如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

默认情况下,您处于公共架构中。您需要使用

导航到您的架构
\d

之后尝试ListBlobs()

答案 1 :(得分:0)

您是否尝试过查询系统表?

SELECT nspname || '.' || relname AS "relation",
    pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
  FROM pg_class C
  LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
  WHERE nspname NOT IN ('pg_catalog', 'information_schema')
    AND C.relkind <> 'i' AND nspname !~ '^pg_toast'
--## change here your schema    
    AND nspname = 'public'
--##
  ORDER BY pg_total_relation_size(C.oid) DESC;

修改

没有pg_total_relation_size函数的相同查询:

SELECT nspname || '.' || relname AS "relation"
FROM pg_class C
  LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
  WHERE nspname NOT IN ('pg_catalog', 'information_schema')
    AND C.relkind = 'r' AND nspname !~ '^pg_toast'
    AND nspname = 'public'
  ORDER BY relname