db.sh

#!/bin/bash
#

user="tercher"
password="123456"
database="$1"
SQL="$2"

mysql -uteacher -p"$password" -D "$database" -N -B -e "$SQL"

命令行我就可以直接指定数据库执行SQL语句了

sh db.sh student "select * from employee" 

我们也可以将查询的结果直接保存在文件中

sh db.sh student "select * from employee" >> result.txt

  

相关文章:

  • 2021-10-26
  • 2022-12-23
  • 2021-03-30
  • 2021-12-04
  • 2022-01-07
  • 2021-12-20
  • 2021-11-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案