snipt

Ctrl+h for KB shortcuts

Text only

Get table size

1
2
3
4
5
6
SELECT 
     table_schema as `Database`, 
     table_name AS `Table`, 
     round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
ORDER BY (data_length + index_length) DESC;
https://snipt.net/embed/43bf75d0b92ac72e6b762eb8579e0c57/
/raw/43bf75d0b92ac72e6b762eb8579e0c57/
43bf75d0b92ac72e6b762eb8579e0c57
text
Text only
6
2024-05-19T14:59:12
True
False
False
/api/public/snipt/65/
get-table-size
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>SELECT </span><span id="L-2"><a name="L-2"></a> table_schema as `Database`, </span><span id="L-3"><a name="L-3"></a> table_name AS `Table`, </span><span id="L-4"><a name="L-4"></a> round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` </span><span id="L-5"><a name="L-5"></a>FROM information_schema.TABLES </span><span id="L-6"><a name="L-6"></a>ORDER BY (data_length + index_length) DESC; </span></pre></div> </td></tr></table>
mysql, mysqli, sql
1
2
3
4
5
6
7
8
9
--- 
+++ 
@@ -0,0 +1,6 @@
+SELECT 
+     table_schema as `Database`, 
+     table_name AS `Table`, 
+     round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
+FROM information_schema.TABLES 
+ORDER BY (data_length + index_length) DESC;