shell 行执行sql,去除字段名

mysql的-e选项可以让我们在命令行下执行sql:

/bin/mysql -h localhost -u {user_name} -p{password} -P 3308 {db_name} -e "select id from {table_name} where uid=1;"
+-------+
| id    |
+-------+
| 10162 |
| 10151 |
| 10152 |
+-------+

发现上面带了字段名id,去掉字段名可以用-N选项(--skip-column-names(-N)):

/bin/mysql -h localhost -u {user_name} -p{password} -P 3308 {db_name} -Ne "select id from {table_name} where uid=1;"
+-------+
| 10162 |
| 10151 |
| 10152 |
+-------+
 

 


原文:https://blog.csdn.net/wusuopubupt/article/details/43952921 
 

你可能感兴趣的:(shell 行执行sql,去除字段名)