Home  >  Article  >  Database  >  MySQL Advanced Six - Function Creation and Use

MySQL Advanced Six - Function Creation and Use

黄舟
黄舟Original
2016-12-29 16:37:301156browse

1. Check whether the function can be created

show variables like '%fun%';

If it is OFF, it means that the function cannot be created

2. Modify the database and the function can be created

set global log_bin_trust_function_creators = 1;

In this way, change it to ON and you can create a function

3. Create a function (the mechanism is similar to creating a stored procedure)

create function fun_add(a int,b int)
returns int
begin
return a+b;
end;
$$;


4. Call fun_add function

select fun_add(2,3);

5. Delete function

drop function if exists fun_add;

6. View function

show create function fun_add;

The above is the content of MySQL Advanced Six - Function Creation and Use. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn