开发者

Redirect input from another command in windows batch files

开发者 https://www.devze.com 2023-02-21 20:49 出处:网络
In linux I 开发者_JAVA技巧can do something like this: mysql -u user -p=pass somedb <(echo \"create database foo;\")

In linux I 开发者_JAVA技巧can do something like this:

mysql -u user -p=pass somedb <(echo "create database foo;")

How can I do that with windows batch scripts?

Basically, I want to make a batch file that runs a sql script without having to keep the script in a separate file.

Thanks


One way is to echo the SQL commands into a file, run the mysql command with option to include the SQL file, and then remove the file (if you really don't want it.)


You can do

echo create database foo;|mysql ...

just fine, but for multiple lines you really want to make a temporary file you just pass to MySQL to read.

0

精彩评论

暂无评论...
验证码 换一张
取 消