1
我想在bash腳本運行的sqlite一系列命令:如何在bash腳本中運行sqlite3?
db="main.sqlite3"
db2="sub.sqlite3"
sqlite3 ${db} <<EOF
attach ${db2} as m;
select count(*) from m.details;
.exit
EOF
當連接到一個字符串,它的工作原理,但是當它是一個變量,它不會,得了
Error: near line 1: near "/": syntax error
如何在EOF中使用變量(db2)?感謝
這應該是寫的。您發佈的代碼段中沒有'/',那麼您是否可以簡化它太多? – Thomas
我建議檢查你的文件是否有特殊字符:'cat -A file'或'cat -v file' – Cyrus
'attach'語句是否需要引用dbname?你需要'附加'$ db2'作爲m;'?我無法從https://sqlite.org/syntax/attach-stmt.html和https://sqlite.org/syntax/expr.html –