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檢視表占用空間大小
需求 我們在選購伺服器硬碟時,通常需要先估算一下資料量。比如我們現在做的專案,百萬級使用者,然後在現有的資料結構中插入一萬條資料,然後根據相應的需求去計算出實際生產中的資料量。前言 在mysql中有乙個預設的資料表information schema,information schema這張資料表儲...
mysql怎麼檢視表占用空間大小
1 進去指定schema 資料庫 存放了其他的資料庫的資訊 use information schema 2 查詢所有資料的大小 select concat round sum data length 1024 1024 2 mb as data from tables 3 檢視指定資料庫的大小 比...
sqlserver檢視表占用空間大小
定義表變數 定義表變數 declare ttable name varchar max rows int reserved varchar max data size varchar max index size varchar max unused size varchar max 將表占用情況存...