11
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PostgresSQLでDBの全テーブルのレコード数一覧を確認

Last updated at Posted at 2016-01-31

お客様から本番環境のDBのダンプデータ貰ってローカル環境構築していたんだけど、本番環境と同じレコード数入ってるのか確認するときに使ったよっ
MySQLとは違いますね。

以下SQL文

SELECT T2.relname 
     , T2.reltuples  
FROM pg_stat_user_tables AS T1 
INNER JOIN pg_class AS T2 
  ON T1.relname = T2.relname 
ORDER BY T2.relname;

これで結果→各テーブル名、レコード数が出力できました。

11
10
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?