没有架构表的PostgreSQL列表表

时间:2014-12-02 22:13:09

标签: postgresql

阅读PostgreSQL文档后,我确定可以使用以下查询在PostgreSQL中创建绝对表名列表...

SELECT tablename FROM pg_catalog.pg_tables ORDER BY tablename ASC;

这会产生一些单独的行(缩减示例列表)......

  

my_table_1

     

my_table_1

     

pg_aggregate里

     

pg_am里

     

pg_amop里

     

sql_features

     

sql_implementation_info

     

sql_languages

不幸的是,这也列出了带有前缀的表,例如pg_sql_,我认为它们是数据库模式的一部分。

如何使用不属于架构的SELECT查询列出表格?

我已经知道如何在PSQL命令行中使用\dtM命令执行此操作,尽管在此实例中它不能满足我的目的。

在示例中,我希望仅返回以下内容...

  

my_table_1

     

my_table_1

1 个答案:

答案 0 :(得分:1)

对于这样的查询,information_schema更容易使用:

select *
from information_schema.tables
where table_schema = 'public';

可替换地:

select *
from information_schema.tables
where table_schema not in ('pg_catalog', 'information_schema');

information_schema.tables已过滤掉temp架构。

相关问题