Answers:
调用mysql用-N(别名为-N是--skip-column-names)选项:
mysql -N ...
use testdb;
select * from names;
+------+-------+
| 1 | pete |
| 2 | john |
| 3 | mike |
+------+-------+
3 rows in set (0.00 sec)
感谢ErichBSchulz指出-N别名。
要删除结果周围的网格(垂直和水平线),请使用-s(--silent)。列用TAB字符分隔。
mysql -s ...
use testdb;
select * from names;
id name
1 pete
2 john
3 mike
要输出没有标题且没有网格的数据,只需使用-s和即可-N。
mysql -sN ...
TABLES=$(mysql -sN -u $DB_USER -p$DB_PASS...
set feedback on并且set feedback off可以在会话的任何地方使用。MySQL是否具有等效功能?看起来这就是OP想要的。
您可以像这样伪造它:
-- with column headings
select column1, column2 from some_table;
-- without column headings
select column1 as '', column2 as '' from some_table;
Error: Type mismatch: expected type string, but got空别名的错误
select column1 as ' ', column2 as ' ' from some_table;
-N