Goal Find the number and percentage of optinal columns in base tables
Type Sofware measure (Numeric values (software measures) about the database)
License MIT License
Data Source INFORMATION_SCHEMA only
SQL Query
SELECT Count(*) FILTER (WHERE C.is_nullable='YES') AS number_of_optional_columns, 
Count(*) AS number_of_columns, 
Round(Count(*) FILTER (WHERE C.is_nullable='YES')::decimal*100/Count(*)::decimal,1) AS percentage_of_optional_columns
FROM information_schema.columns C INNER JOIN information_schema.tables T USING (table_schema, table_name)
INNER JOIN information_schema.schemata S ON T.table_schema = S.schema_name
WHERE T.table_type = 'BASE TABLE' 
AND (T.table_schema = 'public' OR S.schema_owner<>'postgres');

Collections

This query belongs to the following collections:

NameDescription
Find problems about integrity constraintsA 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 overviewQueries 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 .
Find quick numeric overview of the databaseQueries that return numeric values showing mostly the number of different types of database objects in the database
Categories

This query is classified under the following categories:

NameDescription
Missing dataQueries of this category provide information about missing data (NULLs) in a database.