Syntax error How to display the result more readable if the string is long stored in MySQL VARCHAR?

How to display the result more readable if the string is long stored in MySQL VARCHAR?



For this, use \G as in the below syntax −

select * from yourTableName\G

Let us first create a table −

mysql> create table DemoTable1482
   -> (
   -> Title varchar(255)
   -> );
Query OK, 0 rows affected (0.52 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable1482 values('Deep Dive using Java with Data Structure And Algorithm');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable1482 values('Introduction To MySQL and MongoDB');
Query OK, 1 row affected (0.12 sec)

Display all records from the table using select statement −

mysql> select * from DemoTable1482;

This will produce the following output −

+--------------------------------------------------------+
| Title                                                  |
+--------------------------------------------------------+
| Deep Dive using Java with Data Structure And Algorithm |
| Introduction To MySQL and MongoDB                      |
+--------------------------------------------------------+
2 rows in set (0.00 sec)

Following is the query to make the output more readable −

mysql> select * from DemoTable1482\G

This will produce the following output −

*************************** 1. row ***************************
Title: Deep Dive using Java with Data Structure And Algorithm
*************************** 2. row ***************************
Title: Introduction To MySQL and MongoDB
2 rows in set (0.00 sec)
Updated on: 2019-12-10T08:09:14+05:30

448 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements