{"id":21927,"date":"2016-06-10T08:08:01","date_gmt":"2016-06-10T08:08:01","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=21927"},"modified":"2024-12-16T14:25:45","modified_gmt":"2024-12-16T14:25:45","slug":"sql-statement-to-view-the-table-columns-and-settings","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/sql-statement-to-view-the-table-columns-and-settings\/","title":{"rendered":"SQL statement to view the table columns and settings"},"content":{"rendered":"<p><strong>Q) Let&#8217;s consider the database table City from the world MySQL database. What are the correct SQL statements to view the table columns and settings?<\/strong><\/p>\n<p>a) DESC City;<br \/>\nb) VIEW City;<br \/>\nc) DESCRIBE City;<br \/>\nd) SHOW City;<\/p>\n<p>Choose the correct options.<\/p>\n<h2>Answer Explanation<\/h2>\n<p>The options b and d are <strong>NOT<\/strong> correct. The statements are not valid SQL statements.<br \/>\nThey result in the following error.<\/p>\n<p><em>mysql&gt; VIEW City;<\/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;VIEW City&#8217; at line 1<\/p>\n<p>Hence, options b and d are incorrect options.<\/p>\n<h2>Correct Answer<\/h2>\n<p>The options a and c are correct.<\/p>\n<p>DESCRIBE statement is used to show the list of table column names and other settings. We can also use the short-form DESC for the command.<\/p>\n<p>Syntax:<br \/>\nDESCRIBE &lt;table_name&gt;;<br \/>\nor<br \/>\nDESC &lt;table_name&gt;;<\/p>\n<p>To view the City table columns and settings, we can use the following statements.<\/p>\n<p><em>mysql&gt; DESC City;<\/em><\/p>\n<p><em>mysql&gt; DESCRIBE City;<\/em><br \/>\n+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>\n| Field | Type | Null | Key | Default | Extra |<br \/>\n+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>\n| ID | int | NO | PRI | NULL | auto_increment |<br \/>\n| Name | char(35) | NO | | | |<br \/>\n| CountryCode | char(3) | NO | MUL | | |<br \/>\n| District | char(20) | NO | | | |<br \/>\n| Population | int | NO | | 0 | |<br \/>\n+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;-+<br \/>\n5 rows in set (0.00 sec)<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21933\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Table-Columns.png\" alt=\"Table Columns\" width=\"1920\" height=\"1080\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Table-Columns.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Table-Columns-300x169.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Table-Columns-1024x576.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Table-Columns-768x432.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Table-Columns-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p><strong>Hence, a and c are correct options.<\/strong><\/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) Let&#8217;s consider the database table City from the world MySQL database. What are the correct SQL statements to view the table columns and settings? a) DESC City; b) VIEW City; c) DESCRIBE City; d) SHOW City; Choose the correct options. Answer Explanation The options b and d are NOT correct. The statements are not [&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-21927","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\/21927","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=21927"}],"version-history":[{"count":12,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/21927\/revisions"}],"predecessor-version":[{"id":26490,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/21927\/revisions\/26490"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=21927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=21927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=21927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}