我们如何更改MySQL存储过程?
如果我们对该过程具有ALTER ROUTINE特权,那么借助ALTER PROCEDURE 语句,我们可以更改MySQL存储过程" title="存储过程">存储过程。为了说明这一点,我们以一个名为“ delete_studentinfo”的存储过程为例,该存储过程具有以下创建语句:
mysql> SHOW CREATE PROCEDURE Delete_studentinfo\G*************************** 1. row ***************************
Procedure: Delete_studentinfo
sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_
ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Create Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `Delete_studentinfo`( IN p_id INT)
BEGIN
DELETE FROM student_info
WHERE ID=p_id;
END
character_set_client: cp850
collation_connection: cp850_general_ci
Database Collation: latin1_swedish_ci
1 row in set (0.01 sec)
在上面的结果集中,很明显在存储过程'delete_studentinfo'中没有注释。现在,借助ALTER PROCEDURE语句,我们可以添加如下注释:
mysql> ALTER PROCEDURE Delete_studentinfo-> COMMENT 'deleting the record'//
现在,可以确认,借助以下查询的结果集,注释已添加到存储过程中:
mysql> SHOW CREATE PROCEDURE Delete_studentinfo\G*************************** 1. row ***************************
Procedure: Delete_studentinfo
sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_
ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Create Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `Delete_studen
tinfo`( IN p_id INT)
COMMENT 'deleting the record'
BEGIN
DELETE FROM student_info
WHERE ID=p_id;
END
character_set_client: cp850
collation_connection: cp850_general_ci
Database Collation: latin1_swedish_ci
1 row in set (0.00 sec)
以上是 我们如何更改MySQL存储过程? 的全部内容, 来源链接: utcz.com/z/316510.html