如何查找PostgreSQL库所有表的行数

今天使用R批量导入Excel数据到PostgreSQL,总共25个excel,导完后被告知有2个excel是一模一样的,但我导入的时候没有记录表名和excel名直接的关系,如何查找是哪两个表重复了呢?

网上找到一段代码,可以获得指定库下所有表的行数,

SELECT schemaname,relname,n_live_tup 
  FROM pg_stat_user_tables 
  ORDER BY n_live_tup DESC;

结合我的表的前缀raw_2014_,轻松寻找到了2个行数一样的表,

How do you find the row count for all your tables in Postgres
SELECT schemaname,relname,n_live_tup 
  FROM pg_stat_user_tables 
  where relname ~ 'raw_2014_'
  ORDER BY n_live_tup DESC;