MySQL Functions | Create Function | MySQL Tutorial

preview_player
Показать описание
In this mysql video, you will be able to create a function in mysql.

A stored function is a set of SQL statements that perform some operation and return a single value.

Just like Mysql in-built function, it can be called from within a Mysql statement.
By default, the stored function is associated with the default database.

Video duration
Intro : 00:00
Function Syntax: 01:02
Create Function : 01:20
Create Function in PHPMyAdmin: 03:45
Call Function: 05:30

Syntax:
CREATE FUNCTION function_name(func_parameter1, func_parameter2, ..)
RETURN datatype [characteristics]
func_body

Parameters used:
function_name:
func_parameter:
It is the argument whose value is used by the function inside its body. You can’t specify to these parameters IN, OUT, INOUT. The parameter declaration inside parenthesis is provided as func_parameter type. Here, type represents a valid Mysql datatype.
datatype:
It is datatype of value returned by function.
characteristics:
The CREATE FUNCTION statement is accepted only if at least one of the characteristics { DETERMINISTIC, NO SQL, or READS SQL DATA } is specified in its declaration.

DELIMITER
The default delimiter is semicolon. You can change the delimiters to create procedures and so on.
The delimiter_character may consist of a single character or multiple characters e.g., // or $$. However, you should avoid using the backslash (\) because it’s the escape character in MySQL.

CREATE FUNCTION require the CREATE ROUTINE privilege.
The parameter list enclosed within parentheses must always be present. If there are no parameters, an empty parameter list of () should be used. Parameter names are not case-sensitive.

Documentation:

#knowledgethrusters #mysql
Рекомендации по теме
Комментарии
Автор

Very well described sister. To the point. Many many thanks. It's really great.

jabedhossain