{"id":21904,"date":"2016-06-10T05:01:13","date_gmt":"2016-06-10T05:01:13","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=21904"},"modified":"2024-12-16T14:25:59","modified_gmt":"2024-12-16T14:25:59","slug":"what-is-the-statement-to-list-the-available-mysql-databases","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/what-is-the-statement-to-list-the-available-mysql-databases\/","title":{"rendered":"What is the statement to list the MySQL databases?"},"content":{"rendered":"<p><strong>Q) What is the statement to list the available MySQL databases?<\/strong><\/p>\n<p>a) LIST DATABASES;<\/p>\n<p>b) SHOW DATABASES;<\/p>\n<p>c) SHOW DATABASES:<\/p>\n<p>d) SHOW DATABASES \\G<\/p>\n<p>Choose all the correct options.<\/p>\n<h2>Explanation<\/h2>\n<p>Let&#8217;s understand why some options are incorrect and the then learn the correct options and reasons for them.<\/p>\n<h2>Incorrect Options<\/h2>\n<p>Options a) and c) are <strong>NOT<\/strong> correct.<\/p>\n<p>LIST DATABASES; is not a valid MySQL statement. We get the following error when we issue the statement. Hence option <strong>a<\/strong> is NOT correct.<\/p>\n<p><em>mysql&gt; LIST DATABASES;<\/em><br \/>\nERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#8216;LIST DATABASES&#8217; at line 1<\/p>\n<p>The valid statement terminator is ; or \\G\u00a0 or \\g. Semi-colon is not the correct statement terminator and the mysql prompt doesn&#8217;t end with the semi-colon. Hence option <strong>c<\/strong> is NOT correct.<\/p>\n<h2><strong>Correct Answer<\/strong><\/h2>\n<p>The correct options are\u00a0<strong> b) and d).<\/strong><\/p>\n<p>SHOW DATABASES; and SHOW DATABASES \\G are valid statements to list the available MySQL databases.<\/p>\n<p>SHOW DATABASES; statement displays the output in tabular format as shown below:<\/p>\n<p><em>mysql&gt; SHOW DATABASES;<\/em><br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n| Database |<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n| information_schema |<br \/>\n| mysql |<br \/>\n| performance_schema |<br \/>\n| sakila |<br \/>\n| sys |<br \/>\n| world |<br \/>\n| worlddemo |<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n7 rows in set (0.00 sec)<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21922\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/LIST-DATABASES-MySQL.png\" alt=\"LIST DATABASES MySQL\" width=\"1920\" height=\"1080\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/LIST-DATABASES-MySQL.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/LIST-DATABASES-MySQL-300x169.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/LIST-DATABASES-MySQL-1024x576.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/LIST-DATABASES-MySQL-768x432.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/LIST-DATABASES-MySQL-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>SHOW DATABASES \\G statement displays the output as row format as shown below:<\/p>\n<p>mysql&gt; SHOW DATABASES \\G<br \/>\n*************************** 1. row ***************************<br \/>\nDatabase: information_schema<br \/>\n*************************** 2. row ***************************<br \/>\nDatabase: mysql<br \/>\n*************************** 3. row ***************************<br \/>\nDatabase: performance_schema<br \/>\n*************************** 4. row ***************************<br \/>\nDatabase: sakila<br \/>\n*************************** 5. row ***************************<br \/>\nDatabase: sys<br \/>\n*************************** 6. row ***************************<br \/>\nDatabase: world<br \/>\n*************************** 7. row ***************************<br \/>\nDatabase: worlddemo<br \/>\n7 rows in set (0.00 sec)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21919\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/List-Available-MySQL-Databases.png\" alt=\"List Available MySQL Databases\" width=\"1920\" height=\"1080\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/List-Available-MySQL-Databases.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/List-Available-MySQL-Databases-300x169.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/List-Available-MySQL-Databases-1024x576.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/List-Available-MySQL-Databases-768x432.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/List-Available-MySQL-Databases-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>Hence, b and d are correct options.<\/p>\n<p>&#8212;<\/p>\n<h2>MySQL Tutorials<\/h2>\n<p>MySQL Tutorials on this website:<\/p>\n<p><a href=\"https:\/\/www.testingdocs.com\/mysql-tutorials-for-beginners\/\">https:\/\/www.testingdocs.com\/mysql-tutorials-for-beginners\/<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q) What is the statement to list the available MySQL databases? a) LIST DATABASES; b) SHOW DATABASES; c) SHOW DATABASES: d) SHOW DATABASES \\G Choose all the correct options. Explanation Let&#8217;s understand why some options are incorrect and the then learn the correct options and reasons for them. Incorrect Options Options a) and c) are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[520],"tags":[],"class_list":["post-21904","post","type-post","status-publish","format-standard","hentry","category-mysql-database","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/21904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=21904"}],"version-history":[{"count":20,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/21904\/revisions"}],"predecessor-version":[{"id":26492,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/21904\/revisions\/26492"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=21904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=21904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=21904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}