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.
- 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.
SELECT sum( data_length + index_length ) / 1024 / 1024 db_size
FROM information_schema.TABLES where table_schema = 'frontaccountingdb'