1. Select information_schema
2. Query the size of disk space occupied by all databases
Select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2), 'MB') as data_size, Concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size From information_schema.tables Group by TABLE_SCHEMA Order by data_length desc;
3. Query the size of disk space occupied by a single database
Select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB') as data_size, Concat(truncate(index_length/1024/1024,2),' MB') as index_size From information_schema.tables where TABLE_SCHEMA = 'database name' Group by TABLE_NAME Order by data_length desc;
- Which data type saves more space TINYTEXT or VARCHAR for variable data length in MySQL?
- How to Import data (.sql fle) in mysql whose size is greater than 200 MB
- What size are the biggest SQL Server database installations in the world?
- Does field size affect query time?
- Connect to External SQL Database in C#
- Efficient way of handling large number of data in MySQL
- Complex SQL query… 3 tables and need the most popular in the last 24 hours using timestamps
- Is mysql compatible with sql-92?
reprinted the original text：SQL statement to see the size of disk space occupied by each database in mysql - CodeDay