Background
[wp_ad_camp_1]
Sometimes you may need to limit the size of a particular MySQL specially for demo applications. Limiting the size of a database requires determining its current size before any insert operation. This article demonstrates how to use SQL to retrieve the current database size.
Software Environment
- Windows 7 Professional SP1
- MySQL 5.6.16 – Community Server (GPL)
The SQL Select Statement
The SQL statement below retrieves the needed data from information_schema.TABLES table. You database user must have priviledge to run queries against the table in information_schema.
[wp_ad_camp_5]
1 2 | SELECT sum( data_length + index_length ) / 1024 / 1024 db_size FROM information_schema.TABLES where table_schema = 'frontaccountingdb' |
Sample Output
[wp_ad_camp_2]