查看MySQL数据库各表大小

时间:2022-07-01 23:07:35

查看MySQL数据库各表大小,table_schema=数据库名称:

SELECT
  t.table_name,
   concat(round(t.data_len / 1024 / 1024, 2),'MB') data_len
FROM (
  SELECT
    '总共' table_name,
    SUM(DATA_LENGTH) data_len
  FROM information_schema.TABLES
  WHERE table_schema = 'dtoa'
  UNION ALL
  SELECT
    table_name,
    DATA_LENGTH data_len
  FROM information_schema.TABLES
  WHERE table_schema = 'dtoa'
) t ORDER BY t.data_len DESC