Here present a simple query that could be particularly useful for those who have hosting with limited space for storing data, it is a question of fact by which you can obtain the size of a MySQL database. The information will be available directly from the database managers are therefore extremely reliable.
But we go straight to the code of our query, as it is easy to note, is based on creating an alias to associate the result of calculation:
<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;">SELECT COUNT(table_name) AS numero_tabelle,</span> SELECT COUNT (table_name) AS numero_tabelle,</span>
<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;">SUM(data_length+index_length) AS dimensione_db</span> SUM (+ data_length index_length) AS dimensione_db</span>
<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;">FROM INFORMATION_SCHEMA.TABLES</span> FROM INFORMATION_SCHEMA.TABLES</span>
<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;">WHERE table_schema = 'database'</span> WHERE TABLE_SCHEMA = 'database'</span>
If you want to limit to count the number of tables available for a database, it will be possible to simplify example as follows:
<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;">SELECT COUNT(table_name) AS numero_tabelle</span> SELECT COUNT (table_name) AS numero_tabelle</span>
<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;">FROM INFORMATION_SCHEMA.TABLES</span> FROM INFORMATION_SCHEMA.TABLES</span>
<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;">WHERE table_schema = 'database'</span> WHERE TABLE_SCHEMA = 'database'</span>
The command example is particularly useful for large databases or when you have the ability to use visual interfaces for managing tables.