Skip to Main Content
MySQL Cookbook
book

MySQL Cookbook

by Paul DuBois
October 2002
Intermediate to advanced content levelIntermediate to advanced
1024 pages
27h 26m
English
O'Reilly Media, Inc.
Content preview from MySQL Cookbook

Making Long Output Lines More Readable

Problem

The output lines from a query are too long. They wrap around and make a mess of your screen.

Solution

Use vertical output format.

Discussion

Some queries generate output lines that are so long they take up more than one line on your terminal, which can make query results difficult to read. Here is an example that shows what excessively long query output lines might look like on your screen:[10]

mysql> SHOW FULL COLUMNS FROM limbs;
+-------+-------------+------+-----+---------+-------+-------------------------
--------+
| Field | Type        | Null | Key | Default | Extra | Privileges
        |
+-------+-------------+------+-----+---------+-------+-------------------------
--------+
| thing | varchar(20) | YES  |     | NULL    |       | select,insert,update,ref
erences |
| legs  | int(11)     | YES  |     | NULL    |       | select,insert,update,ref
erences |
| arms  | int(11)     | YES  |     | NULL    |       | select,insert,update,ref
erences |
+-------+-------------+------+-----+---------+-------+-------------------------
--------+

An alternative is to generate “vertical” output with each column value on a separate line. This is done by terminating a query with \G rather than with a ; character or with \g. Here’s what the result from the preceding query looks like when displayed using vertical format:

mysql> SHOW FULL COLUMNS FROM limbs\G *************************** 1. row *************************** Field: thing Type: varchar(20) Null: YES Key: Default: NULL Extra: Privileges: select,insert,update,references ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

MySQL Reference Manual

MySQL Reference Manual

Michael Widenius, David Axmark, Kaj Arno
High Performance MySQL

High Performance MySQL

Jeremy D. Zawodny, Derek J. Balling
MySQL Stored Procedure Programming

MySQL Stored Procedure Programming

Guy Harrison, Steven Feuerstein

Publisher Resources

ISBN: 0596001452Catalog PageErrata