Mysql 获取不带表格式的sql查询结果

Mysql 获取不带表格式的sql查询结果,mysql,sql,shell,Mysql,Sql,Shell,像--禁用列名选项一样,我们是否有一个不使用表格式获取sql查询的选项 例如: mysql-u用户名-ppassword——禁用列名——执行“从测试中选择名称” 结果如下: ----- | A | | B | | C | | D | ----- 是否可以使用以下sql程序选项修饰符获得查询结果,[不使用表格式] A B C D 将-B选项添加到mysql mysql -B -u username -ppassword \ --disable-column-names \

--禁用列名
选项一样,我们是否有一个不使用表格式获取sql查询的选项

例如:

mysql-u用户名-ppassword——禁用列名——执行“从测试中选择名称”

结果如下:

-----
| A |
| B |
| C |
| D |
-----
是否可以使用以下sql程序选项修饰符获得查询结果,[不使用表格式]

A
B
C
D

-B
选项添加到
mysql

mysql -B -u username -ppassword \
      --disable-column-names \
      --execute "select name from mydb.test"
-B--batch:以非tabular输出格式打印结果

--execute:执行语句并退出


编辑:感谢@joescii,
-B
,它是
--batch
的缩写,还启用了
--silent
开关。

尽管其他答案可以顺便使用,但正确的开关实际上是
-s
,它是
--silent
的缩写

您可能希望为
--raw
输出另外指定
-r
,这也会禁用字符转义,否则换行符、制表符、空字符和反斜杠将分别表示为\n、\t、\0和\

-甲骨文公司

MySQL 5.7 2018年7月6日


您可以使用
SELECT。。到OUTFILE“file\u name”中导出选项
nice for a export-在mysql客户端中有什么方法吗?
-b
不推荐使用,请改用
--batch
。要从sql脚本执行此操作,最好将
--database
选项添加到命令行。
   ·   --silent, -s

       Silent mode. Produce less output. This option can be given multiple
       times to produce less and less output.

       This option results in nontabular output format and escaping of
       special characters. Escaping may be disabled by using raw mode; see
       the description for the --raw option.

   ·   --raw, -r

       For tabular output, the “boxing” around columns enables one column
       value to be distinguished from another. For nontabular output (such
       as is produced in batch mode or when the --batch or --silent option
       is given), special characters are escaped in the output so they can
       be identified easily. Newline, tab, NUL, and backslash are written
       as \n, \t, \0, and \\. The --raw option disables this character
       escaping.

       The following example demonstrates tabular versus nontabular output
       and the use of raw mode to disable escaping:

           % mysql
           mysql> SELECT CHAR(92);
           +----------+
           | CHAR(92) |
           +----------+
           | \        |
           +----------+
           % mysql -s
           mysql> SELECT CHAR(92);
           CHAR(92)
           \\
           % mysql -s -r
           mysql> SELECT CHAR(92);
           CHAR(92)
           \