Home > Database > Mysql Tutorial > body text

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

Susan Sarandon
Release: 2024-11-15 21:12:03
Original
236 people have browsed it

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 ...
Copy after login

For example:

mysql -N ...
use testdb;
select * from names;
Copy after login

Example Output (with Column Headers):

+------+-------+
| id | name |
+------+-------+
| 1 | pete
| 2 | john
| 3 | mike
+------+-------+
Copy after login

Example Output (without Column Headers):

1 pete
2 john
3 mike
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template