溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQL中怎樣查看數據庫表容量大小

發布時間:2021-08-04 16:43:57 來源:億速云 閱讀:208 作者:Leah 欄目:數據庫

這期內容當中小編將會給大家帶來有關MySQL中怎樣查看數據庫表容量大小,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

  information_schema簡介

  在MySQL中,把 information_schema 看作是一個數據庫,確切說是信息數據庫。其中保存著關于MySQL服務器所維護的所有其他數據庫的信息。如數據庫名,數據庫的表,表欄的數據類型與訪問權限等。

  SCHEMATA表:提供了當前mysql實例中所有數據庫的信息。

  TABLES表:提供了關于數據庫中的表的信息(包括視圖)。詳細表述了某個表屬于哪個schema,表類型,表引擎,創建時間等信息。

  COLUMNS表:提供了表中的列信息。詳細表述了某張表的所有列以及每個列的信息。

  STATISTICS表:提供了關于表索引的信息。

  下面是使用information_schema表查看數據庫信息的案例:

  查看所有數據庫容量大小

  select

  table_schema as '數據庫',

  sum(table_rows) as '記錄數',

  sum(truncate(data_length/1024/1024, 2)) as '數據容量(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

  查看所有數據庫各表容量大小

  select

  table_schema as '數據庫',

  table_name as '表名',

  table_rows as '記錄數',

  truncate(data_length/1024/1024, 2) as '數據容量(MB)',

  truncate(index_length/1024/1024, 2) as '索引容量(MB)'

  from information_schema.tables

  order by data_length desc, index_length desc

  查看(指定庫)mysql庫容量大小

  select

  table_schema as '數據庫',

  sum(table_rows) as '記錄數',

  sum(truncate(data_length/1024/1024, 2)) as '數據容量(MB)',

  sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'

  from information_schema.tables

  where table_schema='mysql';

  查看(指定庫)mysql庫各表容量大小

  select

  table_schema as '數據庫',

  table_name as '表名',

  table_rows as '記錄數',

  truncate(data_length/1024/1024, 2) as '數據容量(MB)',

  truncate(index_length/1024/1024, 2) as '索引容量(MB)'

  from information_schema.tables

  where table_schema='mysql'

  order by data_length desc, index_length desc;

上述就是小編為大家分享的MySQL中怎樣查看數據庫表容量大小了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女