使用命令行执行 MySQL 存储过程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3828341/
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
Execute MySQL Stored Procedure using Command Line
提问by Maxymus
Please help me out to execute a MySQL Stored procedure in command line, where the procedure contains conditional statements..
请帮我在命令行中执行一个 MySQL 存储过程,其中该过程包含条件语句..
回答by dogbane
$ mysql --user=user_name --password=your_password db_name
mysql> call stored_procedure_name();
or
或者
$ mysql --user=user_name --password=your_password db_name < script.sql
where script.sql
contains your sql statement:
其中script.sql
包含您的 sql 语句:
call stored_procedure_name();
回答by Mikhail
Or:
或者:
mysql --user=your_username --execute="call stored_procedure_name()" db_name
The same as:
等同于:
mysql ... -e "call stored_procedure_name()" ...
回答by Andy Mc
Or if you don't want to create a .sql file:
或者,如果您不想创建 .sql 文件:
$ mysql -u your_username --password=your_password db_name <<!!
call stored_procedure_name();
!!
回答by biniam
If you have parameters,
如果你有参数,
call stored_procedure_name(intValue, doubleValue, 'dateValue');
If your stored procedure doesnot take parameters,
如果您的存储过程不带参数,
call stored_procedure_name();