- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to display records vertically in MySQL command line?
You can use backward slash followed by G i.e. \G instead of semicolon(;). The syntax is as follows to show records vertically in MySQL command line.
SELECT *FROM yourTableName\G
To understand the above syntax, let us create a table. The query to create a table is as follows
mysql> create table showRecordsVertically -> ( -> Id int, -> Name varchar(100), -> Age int -> ); Query OK, 0 rows affected (2.10 sec)
Insert some records in the table using insert command. The query is as follows
mysql> insert into showRecordsVertically values(101,'John',23); Query OK, 1 row affected (0.15 sec) mysql> insert into showRecordsVertically values(104,'Carol',20); Query OK, 1 row affected (0.17 sec) mysql> insert into showRecordsVertically values(107,'Bob',22); Query OK, 1 row affected (0.11 sec) mysql> insert into showRecordsVertically values(110,'David',29); Query OK, 1 row affected (0.21 sec) mysql> insert into showRecordsVertically values(113,'Mike',28); Query OK, 1 row affected (0.14 sec)
Now you can show records vertically using \G. The query is as follows
mysql> select *from showRecordsVertically\G
The following is the output
*************************** 1. row *************************** Id: 101 Name: John Age: 23 *************************** 2. row *************************** Id: 104 Name: Carol Age: 20 *************************** 3. row *************************** Id: 107 Name: Bob Age: 22 *************************** 4. row *************************** Id: 110 Name: David Age: 29 *************************** 5. row *************************** Id: 113 Name: Mike Age: 28 5 rows in set (0.00 sec)
- Related Articles
- How to list databases vertically in MySQL command line?
- How to adjust display settings of MySQL command line?
- How to display the value of a variable on command line in MySQL?
- How to open MySQL command line on Windows10?
- How to upgrade MySQL server from command line?
- How can I display MySQL query result vertically?
- How to create a database on command line in MySQL?
- How to repair MySQL tables from the command line?
- How can we return to windows command shell from MySQL command line tool?
- The MySQL Command-Line Client
- Connect to MySQL database from command line
- Display records ignoring NULL in MySQL
- How to find the MySQL data directory from command line in Windows?
- Connecting to MySQL database from the command line?
- Find and display duplicate records in MySQL?

Advertisements