-- 1. 进入information_schema 数据库(存放了其他的数据库的信息)
use information_schema; -- 2. 查询所有数据的大小:
select concat(round(sum(data_length/1024/1024),2),'MB') as data
from information_schema.tables
; -- 3. 查看实例下所有数据库的空间占用情况
select
table_schema
,concat(round(sum(data_length/1024/1024),2),'MB') as data
from information_schema.tables
where table_schema like 'db_name_%'
group by table_schema
; -- 4.查看指定数据库的大小:
select concat(round(sum(data_length/1024/1024),2),'MB') as data
from information_schema.tables
where table_schema='home'
; -- 5. 查看指定数据库下的所有表的空间占用情况
select table_name,round(sum(data_length/1024/1024),2) as size
from information_schema.tables
where table_schema='DB_NAME'
group by table_name
order by size
; -- 6. 查看指定数据库的某个表的大小
select concat(round(sum(data_length/1024/1024),2),'MB') as data
from information_schema.tables
where table_schema='home' and table_name='members'
;
select table_schema ,round(sum(data_length/1024/1024),2) as data_length ,round(sum(DATA_FREE/1024/1024),2) as data_free ,round(sum(INDEX_LENGTH/1024/1024),2) as INDEX_LENGTHfrom information_schema.tables where table_schema='DB_NAME'group by table_schemaorder by data_length;
select
TABLE_SCHEMA
,sum(DATA_LENGTH)/1024/1024/1024 as size_DATA_LENGTH_g
,sum(INDEX_LENGTH)/1024/1024/1024 as size_INDEX_LENGTH_g
,sum(DATA_FREE)/1024/1024/1024 as size_DATA_FREE_g
,sum((DATA_LENGTH+INDEX_LENGTH+DATA_FREE))/1024/1024/1024 as size_g
from information_schema.tables
where table_type = 'BASE TABLE'
group by TABLE_SCHEMA
order by size_DATA_FREE_g
; select
TABLE_NAME
,sum(DATA_LENGTH)/1024/1024/1024 as size_DATA_LENGTH_g
,sum(INDEX_LENGTH)/1024/1024/1024 as size_INDEX_LENGTH_g
,sum(DATA_FREE)/1024/1024/1024 as size_DATA_FREE_g
,sum((DATA_LENGTH+INDEX_LENGTH+DATA_FREE))/1024/1024/1024 as size_g
from information_schema.tables
where table_type = 'BASE TABLE'
and table_schema = 'db_name'
-- and TABLE_NAME = 'table_name'
group by TABLE_NAME
order by size_g desc
limit 20
;

用SQL命令查看Mysql数据库大小 统计数据库空间占用的更多相关文章

  1. SQL命令查看Mysql数据库大小

    SQL命令查看Mysql数据库大小的方法. 要想知道每个数据库的大小的话,步骤如下:1.进入information_schema 数据库(存放了其他的数据库的信息)use information_sc ...

  2. 用SQL命令查看Mysql数据库大小

    要想知道每个数据库的大小的话,步骤如下: 1.进入information_schema 数据库(存放了其他的数据库的信息) use information_schema; 2.查询所有数据的大小: s ...

  3. 使用SQL命令查看MYSQL数据库大小

    mysql> mysql> use information_schema ; /*切换到information_schema数据下*/ Database changed mysql> ...

  4. 查看MySQL数据库大小

    查看MySQL数据库大小 1.首先进入information_schema 数据库(存放了其他的数据库的信息) ? 1 2 mysql> use information_schema; Data ...

  5. mysql管理 ------查看 MySQL 数据库中每个表占用的空间大小

    如果想知道MySQL数据库中每个表占用的空间.表记录的行数的话,可以打开MySQL的 information_schema 数据库.在该库中有一个 TABLES 表,这个表主要字段分别是: TABLE ...

  6. 查看 MySQL 数据库中每个表占用的空间大小

    TABLE_SCHEMA : 数据库名TABLE_NAME:表名ENGINE:所使用的存储引擎TABLES_ROWS:记录数DATA_LENGTH:数据大小INDEX_LENGTH:索引大小 SELE ...

  7. 使用select和show命令查看mysql数据库系统信息

    (1).select 显示当前日期和时间 mysql> select now(); +---------------------+ | now() | +-------------------- ...

  8. 查看mysql数据库版本方法总结

    当你接手某个mysql数据库管理时,首先你需要查看维护的mysql数据库版本:当开发人员问你mysql数据库版本时,而恰好你又遗忘了,那么此时也需要去查看mysql数据库的版本............ ...

  9. 查看mysql数据库体积

    查看MySQL数据库大小 1.首先进入information_schema 数据库(存放了其他的数据库的信息) ? 1 2 mysql> use information_schema; Data ...

  10. 查看MySQL数据库表的命令介绍

    如果需要查看MySQL数据库中都有哪些MySQL数据库表,应该如何实现呢?下面就为您介绍查看MySQL数据库表的命令,供您参考. 进入MySQL Command line client下查看当前使用的 ...

随机推荐

  1. 使用c++ onnxruntime构建项目出现的bug

    bug1:The given version [11] is not supported, only version 1 to 7 is supported in this build. 应该是加载了 ...

  2. logback.xml文件

    <?xml version = "1.0" encoding="UTF-8"?> <configuration debug = "f ...

  3. 71.登录失效,token过期怎么处理

    1. 清除用户数据,直接跳转登录页重新登录 : 2. 短token 过期,使用 长 token 重新获取短 token ,然后重新请求 : 如果长 token 也过期了,就去重新登录获取 token ...

  4. 014 Python 的数据类型(数字、字符串、列表、字典)

    #!/usr/bin/env python # -*- coding:utf-8 -*- # Datatime:2022/7/24 20:31 # Filename:014 Python 的数据类型( ...

  5. js中window全局变量

    .markdown-body { line-height: 1.75; font-weight: 400; font-size: 16px; overflow-x: hidden; color: rg ...

  6. 云原生爱好者周刊:在浏览器中运行 Linux 系统 | 2022-10-10

    Confluent 官网已经放出了<Kafka 权威指南第二版:大规模实时数据和流处理>,相比于第一版新增了以下内容: Kafka 管理客户端概述: API 更新到最新的 Apache K ...

  7. 快速搭建hadoop,zk,hbase的基础集群

    1. ZK集群,Hadoop集群,Hbase集群安装 Linux121 Linux122 Linux123 Hadoop MySQL ZK HBASE 1.1 安装Vmware,安装虚拟机集群 1.1 ...

  8. DC-1内网靶机入门

    DC-1 1.安装dc-1 靶机 2.内网扫描 查看主机IP ip a ifconfig nmap扫描全网段 nmap -A -p- -v 192.168.27.0/24 -A 选项会执行操作系统探测 ...

  9. 有Redis为什么还要本地缓存?谈谈你对本地缓存的理解?

    本地缓存是将数据存储在应用程序所在的本地内存中的缓存方式.既然,已经有了 Redis 可以实现分布式缓存了,为什么还需要本地缓存呢?接下来,我们一起来看. 为什么需要本地缓存? 尽管已经有 Redis ...

  10. STATA数据统计软件学习记录

    STATA是一个数据统计软件,正如它的名字一样,STATA=statistic+data.STATA软件的功能和matlab类似,也可以用代码实现数据的统计与可视化.但几乎只能进行整行整列的数据处理, ...