Skip to content

materialized views in dbListTables() #251

@dpprdan

Description

@dpprdan

Should Materialized Views be listed by dbListTables()?

I'd argue they should since they are objects that share characteristics of both Tables and Views, both of which are returned by dbListTables(), see #27 & #29.

See this thread on the psql-hackers list for a discussion on why they are not in the INFORMATION_SCHEMA.tables (which includes Views). Tl;dr: "They are not defined by the SQL standard." I see this as a relatively minor point w.r.t. RPostgres, though.

As it stands there is no helper function like dbListTables() to list Materialized Views in RPostgres.

The following query shows all Tables, Views and Materialized Views (I have not looked into temporary tables, yet):

SELECT tablename AS name FROM pg_tables WHERE schemaname = ANY (current_schemas(false))
UNION
SELECT viewname AS name FROM pg_views WHERE schemaname = ANY (current_schemas(false))
UNION
SELECT matviewname as name FROM pg_matviews WHERE schemaname = ANY (current_schemas(false))
ORDER BY name;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions