Count of rows

From: Paul Lambert <paul(dot)lambert(at)autoledgers(dot)com(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Subject: Count of rows
Date: 2007-08-03 05:35:26
Message-ID: 46B2BE9E.8010202@autoledgers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

What's the best way to count how many rows are in each table via SQL? Or
is it even possible?

I'm trying something like:

select tablename, count(*) from (select tablename from pg_tables where
schemaname = 'public') as test group by tablename;

But obviously this just gives a count of 1 for each table in the public
schema.

Can it be done or would I have to write a function?

--
Paul Lambert
Database Administrator
AutoLedgers

Browse pgsql-sql by date

  From Date Subject
Next Message Christian Kindler 2007-08-03 07:20:45 Re: Count of rows
Previous Message Kenneth Gonsalves 2007-08-03 01:15:06 Re: Authentification failed