Do not have in a database elements that are not useful. PostgreSQL permits tables with no columns. Such tables can be used to implement Boolean variables (tables TABLE_DEE and TABLE_DUM). On the other hand, such tables might be a result of database evolution, where developers have not noticed that they have dropped all the columns of a table or have not noticed that they have created such a table in the first place.
Notes
The query considers only columns that are visible to the database user and not hidden system columns.
Type
Problem detection (Each row in the result could represent a flaw in the design)
If the table was not created intentionally, then add a column or drop the table.
Data Source
INFORMATION_SCHEMA+system catalog
SQL Query
SELECT table_schema, table_name, table_type
FROM INFORMATION_SCHEMA.tables AS t
WHERE NOT EXISTS (SELECT 1
FROM INFORMATION_SCHEMA.columns AS c
WHERE t.table_schema=c.table_schema
AND t.table_name=c.table_name)
UNION SELECT nspname, relname, 'MATERIALIZED VIEW' AS table_type
FROM pg_class AS c INNER JOIN pg_namespace AS n ON c.relnamespace=n.oid
WHERE NOT EXISTS (SELECT 1
FROM pg_attribute AS a
WHERE c.oid=a.attrelid)
ORDER BY table_schema, table_name, table_type;
Collections
This query belongs to the following collections:
Name
Description
Find problems automatically
Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
Categories
This query is classified under the following categories:
Name
Description
Stubs
Queries of this catergory provide information about stubs (piece of code used to stand in for some other programming functionality).