Query goal: | Find the number of tables (base, foreign, and derived) in different schemas. |
Notes about the query: | The query (due to the use of CUBE) also finds the number of tables in different schemas, the number of different types of tables, and the total number of tables. The query only returns data about schemas that have at least one table. |
Query type: | Sofware measure (Numeric values (software measures) about the database) |
Query license: | MIT License |
Data source: | INFORMATION_SCHEMA+system catalog |
SQL query: | Click on query to copy it
WITH tables_union AS (SELECT tables.table_schema, tables.table_type FROM information_schema.tables WHERE table_schema NOT IN (SELECT schema_name FROM INFORMATION_SCHEMA.schemata WHERE schema_name<>'public' AND schema_owner='postgres' AND schema_name IS NOT NULL) UNION ALL SELECT schemaname AS table_schema, 'MATERIALIZED VIEW' AS table_type FROM pg_catalog.pg_matviews) SELECT table_schema, table_type, count(*) AS number_of_tables FROM tables_union GROUP BY CUBE (table_schema, table_type) ORDER BY table_schema, table_type; |
Collection name | Collection description |
---|---|
Find problems about base tables | A selection of queries that return information about the data types, field sizes, default values as well as general structure of base tables. Contains all the types of queries - problem detection, software measure, and general overview |
Find problems about integrity constraints | A selection of queries that return information about the state of integrity constraints in the datadabase. Contains all the types of queries - problem detection, software measure, and general overview |
Find problems by overview | Queries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not . |
Category name | Category description |
---|---|
Derived tables | Queries of this category provide information about the derived tables (views, materialized views), which are used to implement virtual data layer. |
Structure of base tables | Queries of this category provide information about the structuring of base tables at the database conceptual level |