• View the size of each library
| The code is as follows |
Copy Code |
SELECT SUM (data_length) +sum (index_length) from information_schema.tables WHERE table_schema= ' database_name '; |
The result is in bytes, except that 1024 is K, except that 1048576 is M.
• View the size of each table
| The code is as follows |
Copy Code |
SELECT table_name,data_length+index_length,table_rows from Information_schema.tables WHERE table_schema= ' Database_ Name ' and table_name= ' table_name '; |
• View the last modified time of the table
| The code is as follows |
Copy Code |
SELECT table_name,update_time from Information_schema.tables where table_schema= ' database_name '; LOG |
The TABLES table for the INFORMATION_SCHEMA library, the main fields are:
Table_schema: Database name
TABLE_NAME: Table name
Engine: the storage engine used
Tables_rows: Number of records
Data_length: Data size
Index_length: Index size
An instance of your own application
| The code is as follows |
Copy Code |
Advanced go to MySQL comes with management library: INFORMATION_SCHEMA Own database: Dbwww58com_kuchecarlib Own table: T_carmodelparamvalue mysql> use INFORMATION_SCHEMA; Database changed Mysql> Select Data_length,index_length -From tables where -Table_schema= ' Dbwww58com_kuchecarlib ' and table_name = ' t_carmodelparamvalue '; +-------------+--------------+ | Data_length | Index_length | +-------------+--------------+ | 166379520 | 235782144 | +-------------+--------------+ 1 row in Set (0.02 sec) Mysql> Select concat (Round (sum (data_length/1024/1024), 2), ' MB ') as DATA_LENGTH_MB, -Concat (Round (sum (index_length/1024/1024), 2), ' MB ') as INDEX_LENGTH_MB -From tables where -Table_schema= ' Dbwww58com_kuchecarlib ' and table_name = ' t_carmodelparamvalue '; +----------------+-----------------+ | DATA_LENGTH_MB | INDEX_LENGTH_MB | +----------------+-----------------+ | 158.67MB | 224.86MB | +----------------+-----------------+ 1 row in Set (0.03 sec) |
MySQL View the size of the database, table footprint