Functions are typically used to return table variables. Stored procedures cant return table variables however, can create tables.
A procedure may or may not return multiple values. A function cannot return more than one value and has to return at least one value.
A function can only have IN parameters while stored procedures can have IN, OUT and INOUT parameters
A FUNCTION always returns a value using the return statement while a PROCEDURE may return one or more values through parameters or may not return at all.
Functions can be used in select or update or delete statement while procedure can't.
Functions are normally used for computations where as procedures are normally used for executing business logic.
A Function returns 1 value only. Procedure can return multiple values.
Stored procedure is precompiled execution plan where as functions are not.
本文详细阐述了数据库中函数与存储过程的主要区别:函数总是返回一个值,而存储过程可以返回多个值;函数只能拥有输入参数,而存储过程可以拥有输入、输出及输入输出参数;函数主要用于计算场景,而存储过程则用于执行业务逻辑。
1976

被折叠的 条评论
为什么被折叠?



