{"id":4,"date":"2014-04-18T15:26:47","date_gmt":"2014-04-18T15:26:47","guid":{"rendered":"http:\/\/www.sqldashboards.com\/b\/?p=4"},"modified":"2014-04-18T15:26:47","modified_gmt":"2014-04-18T15:26:47","slug":"sql-pie-chart-mysql","status":"publish","type":"post","link":"https:\/\/www.sqldashboards.com\/b\/sql-pie-chart-mysql\/","title":{"rendered":"SQL Pie Chart MYSQL"},"content":{"rendered":"<p>I came across this interesting post on ASCII pie charts for MySQL. I thought I&#8217;d use our command line tool <a href=\"http:\/\/www.sqldashboards.com\/sqlchart\">sqlChart<\/a> todraw the database pie chart instead.<\/p>\n<p>[raw]<br \/>\n <textarea rows='10' cols='80' class='code' id='mysql-pie-chart-code-113'><br \/>\nc:\\Program Files (x86)\\TimeStored.com\\sqlDashboards>mysql -s mysql -u root &#8211;password=pp -D sakila<br \/>\n  -e &#8220;SELECT * FROM (SELECT table_name,data_length + index_length AS size FROM information_schema.TABLES WHERE table_schema = &#8216;sakila&#8217;) a<br \/>\n  WHERE SIZE IS NOT NULL ORDER BY SIZE DESC LIMIT 8&#8221;<\/p>\n<p>table_name      size<br \/>\nrental  2850816<br \/>\npayment 2228224<br \/>\ninventory       376832<br \/>\nfilm_text       325440<br \/>\nfilm_actor      278528<br \/>\nfilm    278528<br \/>\ncustomer        131072<br \/>\nstaff   98304<\/p>\n<p>c:\\Program Files (x86)\\TimeStored.com\\sqlDashboards>sqlchart -s mysql -u root &#8211;password=pp -D sakila -e &#8220;SELECT *<br \/>\nFROM (SELECT table_name,data_length + index_length AS size FROM information_schema.TABLES WHERE table_schema = &#8216;sakila&#8217;) a<br \/>\n WHERE SIZE IS NOT NULL ORDER BY SIZE DESC LIMIT 8&#8221; -o c:\\temp\\aa\\sizes.png -c piechart<br \/>\nc:\\temp\\aa\\sizes.png<br \/>\n<\/textarea><script type='text\/javascript'>var myCodeMirror = CodeMirror.fromTextArea(document.getElementById('mysql-pie-chart-code-113'), {lineNumbers: true, matchBrackets: true, indentUnit: 4, tabMode: 'default', mode: 'text\/x-plsql', readOnly:true });<\/script><br \/>\n[\/raw]<\/p>\n<p>Simply changing our mysql command to sqlchart and adding the additional arguments<br \/>\n<code>\"-o c:\\temp\\aa\\sizes.png -c piechart\"<\/code><br \/>\ngives us the following SQL Pie Chart:<br \/>\n<div id=\"attachment_5\" style=\"width: 410px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-5\" loading=\"lazy\" src=\"http:\/\/www.sqldashboards.com\/b\/wp-content\/uploads\/2014\/04\/sizes.png\" alt=\"MySQL Sakila Table Sizes Pie Chart\" width=\"400\" height=\"300\" class=\"size-full wp-image-5\" srcset=\"https:\/\/www.sqldashboards.com\/b\/wp-content\/uploads\/2014\/04\/sizes.png 400w, https:\/\/www.sqldashboards.com\/b\/wp-content\/uploads\/2014\/04\/sizes-300x225.png 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><p id=\"caption-attachment-5\" class=\"wp-caption-text\">MySQL Sakila Table Sizes Pie Chart<\/p><\/div><\/p>\n<p>Notice because sqlchart&#8217;s command line arguments closely resemble the mysql command line options, we can quickly change the calls from querying to graphing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I came across this interesting post on ASCII pie charts for MySQL. I thought I&#8217;d use our command line tool sqlChart todraw the database pie chart instead. [raw] c:\\Program Files (x86)\\TimeStored.com\\sqlDashboards>mysql -s mysql -u root &#8211;password=pp -D sakila -e &#8220;SELECT * FROM (SELECT table_name,data_length + index_length AS size FROM information_schema.TABLES WHERE table_schema = &#8216;sakila&#8217;) a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,1],"tags":[6,4,5,3],"_links":{"self":[{"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/posts\/4"}],"collection":[{"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":4,"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"predecessor-version":[{"id":9,"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/posts\/4\/revisions\/9"}],"wp:attachment":[{"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqldashboards.com\/b\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}