Execute MySQL Stored Procedure using Command Line

后端 未结 4 1049
名媛妹妹
名媛妹妹 2021-02-07 10:56

Please help me out to execute a MySQL Stored procedure in command line, where the procedure contains conditional statements..

相关标签:
4条回答
  • 2021-02-07 11:03

    If you have parameters,

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

    If your stored procedure doesnot take parameters,

    call stored_procedure_name();
    
    0 讨论(0)
  • 2021-02-07 11:04

    Or:

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

    The same as:

    mysql ...  -e "call stored_procedure_name()" ...
    
    0 讨论(0)
  • 2021-02-07 11:14

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

    $ mysql -u your_username --password=your_password db_name <<!!
    call stored_procedure_name();
    !!
    
    0 讨论(0)
  • 2021-02-07 11:17
    $ 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();
    
    0 讨论(0)
提交回复
热议问题