SELECT table_schema, table_name, column_name, data_type, character_maximum_length
FROM INFORMATION_SCHEMA.columns
WHERE data_type~*'(char|text)' AND character_maximum_length IS NOT NULL 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)
AND column_name~*'(kood|code)'
ORDER BY data_type, character_maximum_length DESC, table_schema, table_name, ordinal_position;
Categories
This query is classified under the following categories:
Name
Description
Field size
Queries of this category provide information about the maximum size of values that can be recorded in column fields
Result quality depends on names
Queries of this category use names (for instance, column names) to try to guess the meaning of a database object. Thus, the goodness of names determines the number of false positive and false negative results.