Home  >  Article  >  Database  >  How to Suppress Column Headers in SQL Statements with `mysql`?

How to Suppress Column Headers in SQL Statements with `mysql`?

Susan Sarandon
Susan SarandonOriginal
2024-11-15 21:12:03235browse

How to Suppress Column Headers in SQL Statements with `mysql`?

How to Omit Column Headers for a SQL Statement

When executing SQL statements in batch mode using the mysql command-line tool, it may be desirable to exclude column headers for specific statements. To achieve this, utilize the -N option.

Using the -N Option:

Invoke mysql with the -N (alias for --skip-column-names) option:

mysql -N ...

For example:

mysql -N ...
use testdb;
select * from names;

Example Output (with Column Headers):

+------+-------+
| id | name |
+------+-------+
| 1 | pete
| 2 | john
| 3 | mike
+------+-------+

Example Output (without Column Headers):

1 pete
2 john
3 mike

Additional Options:

  • -s (--silent): Removes the grid around the results. Columns are separated by TAB characters.
  • -sN: Suppresses both column headers and the grid.

By utilizing these options, you can tailor the output of your SQL statements to suit your specific needs.

The above is the detailed content of How to Suppress Column Headers in SQL Statements with `mysql`?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn