问题描述
我正在批量执行一些 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 语句的列标题输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)