Suppressing Column Headings in Query Output
Problem
You don’t want to include column headings in query output.
Solution
Turn headings off with the appropriate command option. Normally,
this is --skip-column-names, but you can also
use
-ss.
Discussion
Tab-delimited format is convenient for generating datafiles that you can import into other programs. However, the first row of output for each query lists the column headings by default, which may not always be what you want. Suppose that you have a program named summarize that produces various descriptive statistics for a column of numbers. If you’re producing output from mysql to be used with this program, you wouldn’t want the header row because it would throw off the results. That is, if you ran a command like this, the output would be inaccurate because summarize would count the column heading:
%mysql -e "SELECT arms FROM limbs" cookbook | summarizeTo create output that contains only data values, suppress the
column header row with the --skip-column-names
option:
%mysql --skip-column-names -e "SELECT arms FROM limbs" cookbook| summarize
You can achieve the same effect as
--skip-column-names by specifying the
“silent” option (-s or
--silent) twice:
%mysql -ss -e "SELECT arms FROM limbs" cookbook | summarizeBecome 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.
Read now
Unlock full access