1、查询整个mysql数据库,整个库的大小;单位转换为MB。
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from information_schema.TABLES
2、查询mysql数据库,某个库的大小;
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
from information_schema.TABLES
where table_schema = 'testdb'
3、查看库中某个表的大小;
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
from information_schema.TABLES
where table_schema = 'testdb'
and table_name = 'test_a'
4、查看mysql库中,test开头的表,所有存储大小;
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
from information_schema.TABLES
where table_schema = 'testdb'
and table_name like 'test%'
500万左右。根据mysql数据库得知:mysql单表容量在500万左右,性能处于最佳状态,此时mysql的BTREE索引树高在3到5之间;而单表最大限已经不再由MySQL限制了,改为电脑容量限制了。首先打开指定的数据库:use
information_schema
如果想看指定数据库中的数据表,可以用如下语句:
select
concat(round(sum(DATA_LENGTH/1024/1024),2),'MB')
as
data
from
TABLES
where
table_schema='AAAA'
and
table_name='BBBB'
如果想看数据库中每个数据表的,可以用如下语句:
SELECT
TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)/1024/1024,2),
'MB')
as
data
FROM
TABLES
WHERE
TABLE_SCHEMA='AAAA'
输出:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)