PostgreSQL and its annoying crosstab
Today, I had to pivot (pun intended) from my usual tasks to help a colleague with a query. The task is deceptively simple: Collect metadata about all columns of a table in a single query. This was to be a function in PostgreSQL that would return a table with the following columns:
table_name
column_name
data_type
total_tows
not_null_count
unique_count
max_value (for integers)
min_value (for integers)
avg_value (for integers)
max_length (for strings)
min_length (for strings)
avg_length (for strin...
Read more at blog.aurelianix.com