欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

MySQL數(shù)據(jù)庫(kù)如何查看表占用空間大小

 更新時(shí)間:2022年06月10日 15:44:18   作者:lfwh  
由于數(shù)據(jù)太大了,所以MYSQL需要瘦身,那前提就是需要知道每個(gè)表占用的空間大小,這篇文章主要給大家介紹了關(guān)于MySQL數(shù)據(jù)庫(kù)如何查看表占用空間大小的相關(guān)資料,需要的朋友可以參考下

前言

在mysql中有一個(gè)默認(rèn)的數(shù)據(jù)表information_schema,information_schema這張數(shù)據(jù)表保存了MySQL服務(wù)器所有數(shù)據(jù)庫(kù)的信息。如數(shù)據(jù)庫(kù)名,數(shù)據(jù)庫(kù)的表,表欄的數(shù)據(jù)類型與訪問(wèn)權(quán)限等。再簡(jiǎn)單點(diǎn),這臺(tái)MySQL服務(wù)器上,到底有哪些數(shù)據(jù)庫(kù)、各個(gè)數(shù)據(jù)庫(kù)有哪些表,每張表的字段類型是什么,各個(gè)數(shù)據(jù)庫(kù)要什么權(quán)限才能訪問(wèn),等等信息都保存在information_schema表里面,所以請(qǐng)勿刪改此表。

1、切換數(shù)據(jù)庫(kù)

use information_schema;

2、查看所有數(shù)據(jù)庫(kù)容量大小

select
table_schema as '數(shù)據(jù)庫(kù)',
sum(table_rows) as '記錄數(shù)',
sum(truncate(data_length/1024/1024, 2)) as '數(shù)據(jù)容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;

3、查看指定數(shù)據(jù)庫(kù)使用大小

short_video庫(kù)名 video_info 表名

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='short_video';

4、查看表使用大小

video_info 表名

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='short_video' and table_name='video_info';

5、查看所有數(shù)據(jù)庫(kù)容量大小

select
table_schema as '數(shù)據(jù)庫(kù)',
sum(table_rows) as '記錄數(shù)',
sum(truncate(data_length/1024/1024, 2)) as '數(shù)據(jù)容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;

6、查看所有數(shù)據(jù)庫(kù)各表容量大小

select
table_schema as '數(shù)據(jù)庫(kù)',
table_name as '表名',
table_rows as '記錄數(shù)',
truncate(data_length/1024/1024, 2) as '數(shù)據(jù)容量(MB)',
truncate(index_length/1024/1024, 2) as '索引容量(MB)'
from information_schema.tables
order by data_length desc, index_length desc;

7、查看指定數(shù)據(jù)庫(kù)容量大小

select
table_schema as '數(shù)據(jù)庫(kù)',
sum(table_rows) as '記錄數(shù)',
sum(truncate(data_length/1024/1024, 2)) as '數(shù)據(jù)容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
where table_schema='short_video';

8、查看指定數(shù)據(jù)庫(kù)各表容量大小

select
table_schema as '數(shù)據(jù)庫(kù)',
table_name as '表名',
table_rows as '記錄數(shù)',
truncate(data_length/1024/1024, 2) as '數(shù)據(jù)容量(MB)',
truncate(index_length/1024/1024, 2) as '索引容量(MB)'
from information_schema.tables
where table_schema='short_video'
order by data_length desc, index_length desc;

總結(jié)

到此這篇關(guān)于MySQL數(shù)據(jù)庫(kù)如何查看表占用空間大小的文章就介紹到這了,更多相關(guān)MySQL查看表占用空間大小內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 解壓版MYSQL中文亂碼問(wèn)題解決方案

    解壓版MYSQL中文亂碼問(wèn)題解決方案

    這篇文章主要介紹了解壓版MYSQL中文亂碼問(wèn)題解決方案,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09
  • Mysql中使用Union—多表合并之行合并

    Mysql中使用Union—多表合并之行合并

    這篇文章主要介紹了Mysql中使用Union—多表合并之行合并,如果我們需要將兩個(gè)select語(yǔ)句的結(jié)果作為一個(gè)整體顯示出來(lái),我們就需要用到union或者union all關(guān)鍵字,union(或稱為聯(lián)合)的作用是將多個(gè)結(jié)果合并在一起顯示出來(lái),需要的朋友可以參考下
    2023-07-07
  • Sphinx/MySQL 協(xié)議支持與SphinxQL應(yīng)用實(shí)例

    Sphinx/MySQL 協(xié)議支持與SphinxQL應(yīng)用實(shí)例

    Sphinx/MySQL 協(xié)議支持與SphinxQL應(yīng)用例子,供大家學(xué)習(xí)參考
    2013-02-02
  • MySQL 5.0.96 for Windows x86 32位綠色精簡(jiǎn)版安裝教程

    MySQL 5.0.96 for Windows x86 32位綠色精簡(jiǎn)版安裝教程

    這篇文章主要介紹了MySQL 5.0.96 for Windows x86 32位綠色精簡(jiǎn)版安裝教程,需要的朋友可以參考下
    2017-10-10
  • mysql 的replace into實(shí)例詳解

    mysql 的replace into實(shí)例詳解

    這篇文章主要介紹了mysql 的replace into實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • MySQL操作數(shù)據(jù)庫(kù)實(shí)戰(zhàn)指南

    MySQL操作數(shù)據(jù)庫(kù)實(shí)戰(zhàn)指南

    這篇文章主要給大家介紹了關(guān)于MySQL數(shù)據(jù)庫(kù)操作庫(kù)的相關(guān)資料,MySQL數(shù)據(jù)庫(kù)是一個(gè)關(guān)系型數(shù)據(jù)庫(kù)管理系統(tǒng),所采用的SQL語(yǔ)言是用于訪問(wèn)數(shù)據(jù)庫(kù)最常用的標(biāo)準(zhǔn)會(huì)語(yǔ)言,需要的朋友可以參考下
    2023-07-07
  • mysql清空表數(shù)據(jù)的兩種方式和區(qū)別解析

    mysql清空表數(shù)據(jù)的兩種方式和區(qū)別解析

    這篇文章主要介紹了mysql清空表數(shù)據(jù)的兩種方式和區(qū)別,本文通過(guò)文字實(shí)例代碼相結(jié)合給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-05-05
  • mysql使用from與join兩表查詢的區(qū)別總結(jié)

    mysql使用from與join兩表查詢的區(qū)別總結(jié)

    這篇文章主要給大家介紹了關(guān)于mysql使用from與join兩表查詢的區(qū)別的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • MySQL之where使用詳解

    MySQL之where使用詳解

    我們需要獲取數(shù)據(jù)庫(kù)表數(shù)據(jù)的特定子集時(shí),可以使用where子句指定搜索條件進(jìn)行過(guò)濾。本文主要介紹了MySQL之where使用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • mysql8.0.19基礎(chǔ)數(shù)據(jù)類型詳解

    mysql8.0.19基礎(chǔ)數(shù)據(jù)類型詳解

    這篇文章主要介紹了mysql8.0.19基礎(chǔ)數(shù)據(jù)類型的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下
    2020-03-03

最新評(píng)論