oracle MYSQL 命令执行多个 .sql 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5294729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MYSQL command to execute multiple .sql files
提问by drquiz
I am wanting to write and execute a single mysql .sql file that will execute multiple other .sql files. I am looking for something equivalent to Oracle's:
我想编写和执行一个 mysql .sql 文件,该文件将执行多个其他 .sql 文件。我正在寻找相当于 Oracle 的东西:
@script1.sql
@script2.sql
@script3.sql
Does MYSQL have a command?
MYSQL 有命令吗?
回答by Jay Dave
From bash or any shell, you can run as follows
从 bash 或任何 shell,您可以按如下方式运行
cat script*.sql | mysql -u root -pYOURPASSWORD dbname
This would execute all for your sql files for 'dbname'
这将为“dbname”的 sql 文件执行所有操作
Cheers!!
干杯!!
回答by zerkms
source script1.sql;
source script2.sql;
...