Suppressing Column Headings in Query Output
1.26.1 Problem
You don't want to include column headings in query output.
1.26.2 Solution
Turn column headings off with the appropriate command-line option. Normally this is -N or --skip-column-names, but you can use -ss instead.
1.26.3 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 you have a program named summarize the 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 | summarize
To create output that contains only data values, suppress the column header row with the -N (or --skip-column-names) option:
% mysql -N -e "SELECT arms FROM limbs" cookbook | summarize
-N and --skip-column-names were introduced in MySQL 3.22.20. For older versions, you can achieve the same effect by specifying the "silent" option (-s or --silent) twice:
% mysql -ss -e "SELECT arms FROM limbs" cookbook | summarize
Under Unix, another alternative is to use tail to skip the first line:
% mysql -e "SELECT arms FROM limbs" cookbook | tail +2 | summarize
Категории