#显示储存过程showprocedurestatus; #设置结束符delimiter $; #创建储存过程Create procedureprocedure_name ()begin --SQL statements End$Create proceduremyshow ()begin Select User(),Database(); End$ #调用储存过程Callprocedure() callprocedure#没有对数时括号可省
Mysql> Usetest$DatabaseChangedmysql> Create proceduremyshow () - begin - Select User(),Database(); - End$Query OK,0Rows Affected (0.03sec) MySQL>Call myshow - $+----------------+------------+| User()| Database()|+----------------+------------+|Root@localhost |Test|+----------------+------------+1Rowinch Set(0.02sec) Query OK,0Rows Affected (0.03sec) MySQL>myshow () $ERROR1064(42000): You had an errorinchyour SQL syntax;CheckThe manual that corresponds toYourmysql Server version forThe RightSyntax to UseNear'myshow ()'At line1MySQL>Call myshow () $+----------------+------------+| User()| Database()|+----------------+------------+|Root@localhost |Test|+----------------+------------+1Rowinch Set(0.00sec) Query OK,0Rows Affected (0.01sec) MySQL>
MySQL Storage procedure 1: Set terminator and stored procedure creation