The list of all the queries

The number and percentage of optinal columns in base tables

Query goal: Find the number and percentage of optinal columns in base tables
Query type: Sofware measure (Numeric values (software measures) about the database)
Query license: MIT License
Data source: INFORMATION_SCHEMA only
SQL query: Click on query to copy it

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 where the query belongs to

Collection nameCollection description
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 where the query belongs to

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

The list of all the queries