在?DBI::dbListTables
中,我们可以阅读:
这应该包括视图和临时对象
的确如此。
但是,如何只查看表,但不包括视图?
如果有问题,我正在使用驱动程序RPostgres::Postgres()
。
我建议表的系统目录视图为pg_tables
:
pg_tables
dbGetQuery(con, "SELECT * FROM pg_tables")
视图The manual:提供对数据库中每个表的有用信息的访问。
不包含视图,实例化视图或临时表,仅包含常规表(包括pg_tables
表)。参见:
您可能要排除系统表,而仅检索模式和表名:
UNLOGGED
我为目录表添加了显式架构限定:How to check if a table exists in a given schema。通常不是必需的,但是可以防止混乱的dbGetQuery(con, "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname !~ '^pg_' AND schemaname <> 'information_schema'")
设置。参见:
pg_catalog.pg_tables
search_path
查看-如果需要的话:
How does the search_path influence identifier resolution and the "current schema"
视图
pg_views
提供对数据库中每个视图的有用信息的访问。