How to adjust display settings of MySQL command line?

MySQLMySQLi Database

To adjust display settings of MySQL command line, use the /G at the end of MySQL queries instead of semicolon(;).

The syntax is as follows −

SELECT *FROM yourTableName \G

The above syntax adjusts the display settings. Here we will display records in row format from our sample ‘studenttable’ table which we created using CREATE −

mysql> create table StudentTable
   −> (
   −> Id int, 
   −> Name varchar(100)
   −> );
Query OK, 0 rows affected (0.65 sec)

To get all the records −

mysql> select *from StudentTable;

The following displays the records −

+------+---------+
| Id   | Name    |
+------+---------+
|    1 | Carol   |
|    2 | John    |
|    3 | Johnson |
+------+---------+
3 rows in set (0.00 sec)

The table ‘studenttable’ have some records that display all records in row format. The query is as follows to adjust display settings −

select *from studenttable \G

The following is the output −

*************************** 1. row ***************************
Id: 1
Name: Carol
*************************** 2. row ***************************
Id: 2
Name: John
*************************** 3. row ***************************
Id: 3
Name: Johnson
3 rows in set (0.04 sec)
raja
Published on 16-Jan-2019 10:05:33
Advertisements