SELECT nspname AS schema_name
FROM pg_namespace AS n INNER JOIN pg_authid AS a ON n.nspowner=a.oid
WHERE (nspname='public' OR rolname<>'postgres')
AND NOT EXISTS (SELECT 1
FROM pg_class AS c
WHERE n.oid=c.relnamespace)
AND NOT EXISTS (SELECT 1
FROM pg_type AS pt
WHERE n.oid=pt.typnamespace)
AND NOT EXISTS (SELECT 1
FROM pg_proc AS pc
WHERE n.oid=pc.pronamespace)
ORDER BY nspname;
SQL statements that help generate fixes for the identified problem.
SQL Query to Generate Fix
Description
SELECT format('DROP SCHEMA %1$I;', nspname) AS statements
FROM pg_namespace AS n INNER JOIN pg_authid AS a ON n.nspowner=a.oid
WHERE (nspname='public' OR rolname<>'postgres')
AND NOT EXISTS (SELECT 1
FROM pg_class AS c
WHERE n.oid=c.relnamespace)
AND NOT EXISTS (SELECT 1
FROM pg_type AS pt
WHERE n.oid=pt.typnamespace)
AND NOT EXISTS (SELECT 1
FROM pg_proc AS pc
WHERE n.oid=pc.pronamespace)
ORDER BY nspname;
Drop the schema.
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
Comfortability of database evolution
Queries of this category provide information about the means that influence database evolution.
Unused implementation elements
Queries of this catergory provide information about the database objects that are not used.