Home > Database > Mysql Tutorial > body text

MySQL Advanced Six - Function Creation and Use

黄舟
Release: 2016-12-29 16:37:30
Original
1116 people have browsed it

1. Check whether the function can be created

show variables like '%fun%';
Copy after login

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;
Copy after login

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;
$$;
Copy after login


4. Call fun_add function

select fun_add(2,3);
Copy after login

5. Delete function

drop function if exists fun_add;
Copy after login

6. View function

show create function fun_add;
Copy after login

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)!


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!