How can I suppress column header output for a single SQL statement?(如何抑制单个 SQL 语句的列标题输出?)
问题描述
我正在批量执行一些 SQL 语句(使用 mysql 命令行二进制文件).我希望我的几个 SELECT 语句之一不打印列标题,只打印选定的记录.这可能吗?
I'm executing some SQL statements in batch (using the mysql command-line binary). I want one of my several SELECT statements to not print the column headers, just the selected records. Is this possible?
推荐答案
使用 -N 调用 mysql(-N 的别名是 --skip-column-names) 选项:
Invoke mysql with the -N (the alias for -N is --skip-column-names) option:
mysql -N ...
use testdb;
select * from names;
+------+-------+
| 1 | pete |
| 2 | john |
| 3 | mike |
+------+-------+
3 rows in set (0.00 sec)
感谢 ErichBSchulz 指出 -N 别名.
Credit to ErichBSchulz for pointing out the -N alias.
要移除结果周围的网格(垂直线和水平线),请使用 -s (--silent).列用 TAB 字符分隔.
To remove the grid (the vertical and horizontal lines) around the results use -s (--silent). Columns are separated with a TAB character.
mysql -s ...
use testdb;
select * from names;
id name
1 pete
2 john
3 mike
要输出没有标题和网格的数据,只需同时使用 -s 和 -N.
To output the data with no headers and no grid just use both -s and -N.
mysql -sN ...
这篇关于如何抑制单个 SQL 语句的列标题输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何抑制单个 SQL 语句的列标题输出?
基础教程推荐
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
