前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >mysql的一些命令行操作指令

mysql的一些命令行操作指令

作者头像
章工运维
发布2024-01-12 09:38:31
发布2024-01-12 09:38:31
16100
代码可运行
举报
文章被收录于专栏:章工运维
运行总次数:0
代码可运行
# 查看数据库大小操作
代码语言:javascript
代码运行次数:0
复制
#查看所有数据库大小
SELECT table_schema AS 'Database',
    SUM(data_length + index_length) / 1024 / 1024 AS 'Total_size_MB'
FROM information_schema.tables
GROUP BY table_schema;
#查看所有数据库表空间大小
SELECT table_schema AS 'Database',
       table_name AS 'Table',
       round(((data_length + index_length) / 1024 / 1024), 2) AS 'Size_MB'
FROM information_schema.tables
ORDER BY data_length + index_length DESC;
#查看某个库所有表空间大小
SELECT table_name AS 'Table',
       round(((data_length + index_length) / 1024 / 1024), 2) AS 'Size_MB'
FROM information_schema.tables
WHERE table_schema = '填数据库名'
ORDER BY data_length + index_length DESC;
#查看数据库表空间碎片大小
SELECT
    table_schema AS `Database`,
    table_name AS `Table`,
    round(((data_length + index_length) / 1024 / 1024), 2) AS `Size (MB)`,
    round((data_free / 1024 / 1024), 2) AS `Free Space (MB)`
FROM
    information_schema.TABLES
WHERE
    table_schema='填数据库名';
#这条语句将重组表并释放未使用的空间,有助于提高表的性能并减少碎片
OPTIMIZE TABLE your_table_name;
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-01-11,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • # 查看数据库大小操作
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档