63
64

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.

備忘:MySQLでテーブルサイズを確認するためのSQL

Last updated at Posted at 2014-07-03

参考:http://d.hatena.ne.jp/sho-yamasaki/20120405/1333640589

特定のデータベースの、テーブル毎のサイズを取得するSQL

select
	table_name,
	table_comment,
	table_rows, 
	avg_row_length,  
	round((data_length + index_length)/1024/1024) as total_size_MB, -- 合計サイズ
	round(data_length/1024/1024) as data_size_MB, -- データサイズ
	round(index_length/1024/1024) as index_size_MB -- インデックスサイズ
from INFORMATION_SCHEMA.TABLES
where table_schema = 'データベース名'
order by total_size_MB desc, data_size_MB desc, index_size_MB desc, table_name
63
64
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
63
64

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?