In this post, I am sharing two different scripts to find the free and occupied size of Table and Database in MySQL.
This script is very useful for DBA for checking the size of tables and databases.
If you find freer space, DBA has to recover free space.
Below are scripts:
1
2
3
4
5
6
7
|
/* Script for Database */
SELECT
table_schema AS DataBase_Name
,ROUND(sum( data_length + index_length ) / 1024 /1024,1) AS OccupiedSize_inMB
,ROUND(sum( data_free )/ 1024 / 1024,1) AS FreeSpace_inMB
FROM information_schema.TABLES
GROUP BY table_schema ;
|
1
2
3
4
5
6
|
/* Script for Tables */
SELECT table_Name AS Table_Name,
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS TableSize_InMB
,ROUND(sum( data_free )/ 1024 / 1024,1) AS FreeSpace_inMB
FROM information_schema.tables
WHERE Table_Schema = 'db_name'
|
0 comments:
Post a Comment