0
1

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.

レコード件数の多い順でソートしてテーブル一覧を取得するSQL

Posted at

MySQLを使用したアプリケーションで運用していると
「あー、データ量増えてきたなー」
「テーブルのレコード数が多いテーブルってどのテーブルで何件あるんだろう?」
って時があります。

そういう時にinformation_schemaからテーブルのレコード数が多い順にソートして取得するSQLです。

select table_name, table_rows from information_schema.TABLES order by table_rows desc;

limitで絞ればレコード数上位10テーブルとかも取得できます。

0
1
0

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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?