按默认排序 显示最新评论 共有8个评论 (最后回答: 7个月前)
-
收藏了
-
这个是数据占用大小?
问下如何查某表的实际物理磁盘占用大小? innodb.
我按照上面查询数据有700+M. 我查看 "table.frm table.par" 这2个才几百K.
-
引用来自“小鸵鸟”的答案
这个是数据占用大小?
问下如何查某表的实际物理磁盘占用大小? innodb.
我按照上面查询数据有700+M. 我查看 "table.frm table.par" 这2个才几百K.
我觉得上面数据 + 索引查出来的 和实际物品磁盘占用大小差不多了。我上面查询是4.5g然后去找存储的文件夹 大小也是4.5g 占用空间 4.98g -
1、进去指定schema 数据库(存放了其他的数据库的信息)
1
mysql> use information_schema;
2
Database
changed
1
mysql>
select
concat(round(
sum
(DATA_LENGTH/1024/1024), 2),
'MB'
)
2
->
as
data
from
TABLES;
3
+
-----------+
4
| data |
5
+
-----------+
6
| 6674.48MB |
7
+
-----------+
8
1 row
in
set
(16.81 sec)
1
mysql>
select
concat(round(
sum
(DATA_LENGTH/1024/1024), 2),
'MB'
)
2
->
as
data
from
TABLES
where
table_schema=
'forexpert'
;
3
+
-----------+
4
| data |
5
+
-----------+
6
| 6542.30MB |
7
+
-----------+
8
1 row
in
set
(7.47 sec)
1
mysql>
select
concat(round(
sum
(DATA_LENGTH/1024/1024),2),
'MB'
)
as
data
2
->
from
TABLES
where
table_schema=
'forexpert'
3
->
and
table_name=
'member'
;
4
+
--------+
5
| data |
6
+
--------+
7
| 2.52MB |
8
+
--------+
9
1 row
in
set
(1.88 sec)
-
收藏之。。。。
-
已经收藏了,谢谢
-
引用来自“铂金小熊”的答案
1、进去指定schema 数据库(存放了其他的数据库的信息)
1
mysql> use information_schema;
2
Database
changed
1
mysql>
select
concat(round(
sum
(DATA_LENGTH/1024/1024), 2),
'MB'
)
2
->
as
data
from
TABLES;
3
+
-----------+
4
| data |
5
+
-----------+
6
| 6674.48MB |
7
+
-----------+
8
1 row
in
set
(16.81 sec)
1
mysql>
select
concat(round(
sum
(DATA_LENGTH/1024/1024), 2),
'MB'
)
2
->
as
data
from
TABLES
where
table_schema=
'forexpert'
;
3
+
-----------+
4
| data |
5
+
-----------+
6
| 6542.30MB |
7
+
-----------+
8
1 row
in
set
(7.47 sec)
1
mysql>
select
concat(round(
sum
(DATA_LENGTH/1024/1024),2),
'MB'
)
as
data
2
->
from
TABLES
where
table_schema=
'forexpert'
3
->
and
table_name=
'member'
;
4
+
--------+
5
| data |
6
+
--------+
7
| 2.52MB |
8
+
--------+
9
1 row
in
set
(1.88 sec)
http://www.oschina.net/question/12_3673
MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句
2013-08-23 07:05:01
分类: Mysql/postgreSQL
在mysql中如何查询所有数据库占用磁盘空间大小的SQL语句.
查询所有数据库占用磁盘空间大小的SQL语句:
查询单个库中所有表磁盘占用大小的SQL语句:
注意替换以上的TestDB为自己的数据库名。
查询所有数据库占用磁盘空间大小的SQL语句:
- select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size,
- concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
- from information_schema.tables
- group by TABLE_SCHEMA --from www.jbxue.com
- order by data_length desc;
- select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB') as data_size,
- concat(truncate(index_length/1024/1024,2),' MB') as index_size
- from information_schema.tables where TABLE_SCHEMA = 'TestDB'
- group by TABLE_NAME --from www.jbxue.com
- order by data_length desc;