开发者

Execute MySQL Stored Procedure using Command Line

Please help me out to execute a MySQL Stored proced开发者_开发百科ure in command line, where the procedure contains conditional statements..


$ 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:

call stored_procedure_name();


Or:

mysql --user=your_username --execute="call stored_procedure_name()" db_name

The same as:

mysql ...  -e "call stored_procedure_name()" ...


Or if you don't want to create a .sql file:

$ mysql -u your_username --password=your_password db_name <<!!
call stored_procedure_name();
!!


If you have parameters,

call stored_procedure_name(intValue, doubleValue, 'dateValue');

If your stored procedure doesnot take parameters,

call stored_procedure_name();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜