首页 » 技术点滴 » 正文

查看 MySQL 或 MariaDB数据库大小

SELECT table_schema AS "Database Name",
  ROUND(SUM(data_length + index_length) / 1024 / 1024, 2)
  AS "Size in (MB)"
  FROM information_schema.TABLES
  GROUP BY table_schema;

查看全部

SELECT table_schema AS "Database Name",
  ROUND(SUM(data_length + index_length) / 1024 / 1024, 2)
  AS "Size in (MB)"
  FROM information_schema.TABLES
  WHERE table_schema = "YOUR_DB_NAME";

查看一个

SELECT table_name AS "Table Name",
  ROUND(((data_length + index_length) / 1024 / 1024), 2)
  AS "Size in (MB)"
  FROM information_schema.TABLES
  WHERE table_schema = "YOUR_DB_NAME"
  ORDER BY (data_length + index_length) DESC;

查询表

发表评论