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%'
--1、查看表空间的名称及大小select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name
--2、查看表空间物理文件的名称及大小
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name
mysql>show databases+--------------------+
| Database |
+--------------------+
| information_schema |
| hnmcc |
| hnmcc_ecp |
| hnmcc_push |
| hnmcc_sso |
| mysql |
| percona|
| performance_schema |
| test |
+--------------------+
9 rows in set (0.00 sec)
// 使用mysql自带管理表information_schema.
mysql>use information_schema;
mysql>select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='hnmcc' and table_name='l_log_20160102'
+-----------+
| data |
+-----------+
| 4803.00MB |
+-----------+
1 row in set (0.00 sec)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)