Query goal: | Find the number of base table columns that use different integer types (SMALLINT, INTEGER, BIGINT) and their proportion from the overall set of columns that use an integer type. |
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 data_type='smallint') AS nr_of_smallint_columns, Round((Count(*) FILTER (WHERE data_type='smallint'))::numeric*100/Count(*)::numeric,1) AS percentage_of_smallint_columns, Count(*) FILTER (WHERE data_type='integer') AS nr_of_integer_columns, Round((Count(*) FILTER (WHERE data_type='integer'))::numeric*100/Count(*)::numeric,1) AS percentage_of_integer_columns, Count(*) FILTER (WHERE data_type='bigint') AS nr_of_bigint_columns, Round((Count(*) FILTER (WHERE data_type='bigint'))::numeric*100/Count(*)::numeric,1) AS percentage_of_bigint_columns FROM INFORMATION_SCHEMA.columns WHERE data_type IN ('smallint', 'integer', 'bigint') AND (table_schema, table_name) IN (SELECT table_schema, table_name FROM INFORMATION_SCHEMA.tables WHERE table_type='BASE TABLE') AND 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); |
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 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 |
---|---|
Data types | Queries of this category provide information about the data types and their usage. |