TIL #9: PostgreSQL SQL query to find column count for all the tables in a PostreSQL schema


Today, I wanted to find column count for all the tables in a PostreSQL schema. The following query could be used.

select table_name, count(*) as column_count 
from information_schema."columns" 
where table_schema = 'public'  
GROUP by table_name order by column_count desc;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s