获取mysql中表的每一行大小?

时间:2014-06-23 12:07:04

标签: mysql

如何获取MySQL中表的每一行大小,即行所占空间的总大小。假设一个表有BLOB列。并非所有行都具有相同的大小。我想列出所有BLOB列,即更大的文本列。同样是单行的集体大小。

是否可以在单个查询中检索表的每个行大小?

1 个答案:

答案 0 :(得分:0)

不确定如何获取表的每一行大小。但是能够找到表,数据库大小的查询。这似乎是不可能的。

从单个数据库列出表大小

假设数据库名称为“example”

SELECT
  TABLE_NAME AS `Table`,
  ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
  information_schema.TABLES
WHERE
  TABLE_SCHEMA = "example"
ORDER BY
  (DATA_LENGTH + INDEX_LENGTH)
DESC;

整个数据库大小

SELECT table_schema "Data Base Name", sum( data_length + index_length) / 1024 / 1024
"Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;

SELECT sum(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024),2)) "Size in MB"
FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = "your_db_name";

SELECT table_schema as 'Database Name', 
        sum( data_length + index_length ) as 'Size in Bytes',       
        round((sum(data_length + index_length) / 1024 / 1024), 4) as 'Size in MB'
 FROM     information_schema.TABLES
 GROUP BY table_schema;