What is the best way to display in Terminal a MySQL SELECT returning too many fields?

MySQLMySQLi Database

<p>To achieve this, you can use the following syntax in MySQL &minus;</p><pre class="prettyprint notranslate">select *from yourTableName\G;</pre><p>Here, G can be used for vertical purpose. You need to add yourTableName.</p><p>Let us create a table in order to understand the above syntax. Creating a table with the help of CREATE command.</p><p>The following is the query to create a table &minus;</p><pre class="prettyprint notranslate">mysql&gt; create table TooManyFieldsreturnDemo -&gt; ( -&gt; Id int, -&gt; Name varchar(100), -&gt; Age int -&gt; ); Query OK, 0 rows affected (0.64 sec)</pre><p>Now you can insert records in the table with the help of INSERT command. The query is as follows &minus;</p><pre class="prettyprint notranslate">mysql&gt; insert into TooManyFieldsreturnDemo values(1,&#39;John&#39;,21); Query OK, 1 row affected (0.19 sec) mysql&gt; insert into TooManyFieldsreturnDemo values(2,&#39;Johnson&#39;,22); Query OK, 1 row affected (0.15 sec) mysql&gt; insert into TooManyFieldsreturnDemo values(3,&#39;Sam&#39;,23); Query OK, 1 row affected (0.10 sec) mysql&gt; insert into TooManyFieldsreturnDemo values(4,&#39;Carol&#39;,24); Query OK, 1 row affected (0.14 sec) mysql&gt; insert into TooManyFieldsreturnDemo values(5,&#39;David&#39;,25); Query OK, 1 row affected (0.12 sec)</pre><p>Now, let us apply the above syntax to achieve the desired result discussed before. The query is as follows &minus;</p><pre class="prettyprint notranslate">mysql&gt; select *from TooManyFieldsreturnDemo\G;</pre><p>Here is the output &minus;</p><pre class="result notranslate">*************************** 1. row *************************** Id: 1 Name: John Age: 21 *************************** 2. row *************************** Id: 2 Name: Johnson Age: 22 *************************** 3. row *************************** Id: 3 Name: Sam Age: 23 *************************** 4. row *************************** Id: 4 Name: Carol Age: 24 *************************** 5. row *************************** Id: 5 Name: David Age: 25 5 rows in set (0.00 sec)</pre>
raja
Updated on 30-Jul-2019 22:30:24

Advertisements