在Redshift中查找给定表名的模式名称。

问题描述 投票:0回答:1

是否可以在redshift中检索给定表名的模式名,并在找不到表时返回错误?

  SELECT * FROM PG_TABLE_DEF WHERE tablename = 'tablename';

似乎没有工作。

sql select amazon-redshift where-clause information-schema
1个回答
1
投票

pg_table_def 让你只看到你当前用户可见的表--这大概不是你正在搜索的表的情况。

你可以使用 pg_tables 代替(这原本是一个Postgre目录视图,被记录为 半无障碍 在Redshift中)。)

select schemaname from pg_tables where tablename = 'mytable';

如果你的表是用区分大小写的标识符创建的,你也可能面临一些大小写问题。在这种情况下。

where lower(tablename) = 'mytable';
© www.soinside.com 2019 - 2024. All rights reserved.