mysql function
mysql 自定义函数的使用
先查看函数功能是否开启:show variables like '%func%';
若是未开启则:SET GLOBAL log_bin_trust_function_creators=1;
关闭则是:SET GLOBAL log_bin_trust_function_creators=0;
@1 创建
DROP function IF EXISTS myzrz;
delimiter //
create function myzrz(x int , y int )
returns int
begin
declare a SMALLINT UNSIGNED DEFAULT 20;
declare b SMALLINT UNSIGNED DEFAULT 10;
return a+b;
end
//
DROP function IF EXISTS myzrz;
说明 语法格式
create function 函数名称 (接收变量名 变量类型,接收变量名 变量类型 )
returns int // 指定返回类型 此处returns 注意
begin
declare 局部变量名1 变量类型 default 默认值 ;
declear 局部变量名2 变量类型 default 默认值 ; //注意声明多个变量要用多个declare 语句切之间用分号隔开
此处定义方法体
return 返回值;
end //结束Begin - end 方法体
删除 drop function 自定义函数名
显示 创建自定义函数的语句 show create function 自定义函数名 ;
查看有哪些自定义函数 show function status;
修改自定义函数 alert function
先写这些 以后用到再补充
mysql function的更多相关文章
- mysql function 与 procedure
Mysql 的 function 和 procedure 有啥区别呢 ? 网上搜索后说 function 有返回值, procedure 无返回值. 1.return 从function 的语法角度 ...
- 关于MySQL function创建的限制
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. MySQL 的function创建会有各种限制,经常使用的语句的限制如下: 1.CONTAINS_DYNAMIC_SQL ...
- mysql function 中使用游标
create function p_t1(tid varchar(20))returns varchar(200)begin declare tmpName varchar(50) default ' ...
- mysql function 查询子级机构
DROP FUNCTION IF EXISTS queryChildOrgList;CREATE FUNCTION queryChildOrgList(id VARCHAR(20))RETURNS V ...
- MySQL FUNCTION 整理
-- 返回最后一个INSERT查询中, AUTO_INCREMENT列设置的第一个表的值. SELECT LAST_INSERT_ID();
- mysql function动态执行不同sql语句
create procedure cps() begin ) default 'user'; set strSql = concat('select * from ',table_user); pre ...
- Node.js Express连接mysql完整的登陆注册系统(windows)
windows学习环境: node 版本: v0.10.35 express版本:4.10.0 mysql版本:5.6.21-log 第一部分:安装node .Express(win8系统 需要&qu ...
- 【Linux】Zabbix + MPM + msmtp + mutt 监控MySQL + 邮件报警
Zabbix部署参考博文 http://blog.sina.com.cn/s/blog_5611597901017oe0.html MPM安装配置参考博文和MPM官网下载地址 http://blog ...
- mysql 5.7安装脚本
[root@HE2 ~]# cat mysql_auto_install.sh ###### 二进制自动安装数据库脚本root密码MANAGER将脚本和安装包放在/root目录即可########## ...
随机推荐
- ACM Changchun 2015 J. Chip Factory
John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage larg ...
- 在spring boot中使用webSocket组件(一)
最近在项目中使用到了spring的webSocket组件,在这里和大家分享下,如有错误,欢迎大家指正. 在这里我使用的IDE工具是Intellij idea,框架是spring boot.spring ...
- goalng导出excel(csv格式)
最近项目中有个小需求,需要将查询结果导出到excel.之间前java比较容易,使用POI很容易就能实现,查了下golang的文档,发现golang下边并没有导出excel的包,但是却有一个encodi ...
- HDU 1533 二分图最小权匹配 Going Home
带权二分图匹配,把距离当做权值,因为是最小匹配,所以把距离的相反数当做权值求最大匹配. 最后再把答案取一下反即可. #include <iostream> #include <cst ...
- const用法归纳总结 C++
非常好的一篇分析const的总结归纳, 在此谢谢原作者:http://blog.csdn.net/zcf1002797280/article/details/7816977 在普通的非 const成员 ...
- python安装和eclipse安装及环境变量配置
非常好的技术文档,链接如下: http://jingyan.baidu.com/article/eb9f7b6da950c4869364e8f5.html 感谢作者的分享 http://python. ...
- dict的特性和基本语法——python3.6
特性 key:value结构,字典中的每一个元素,都是键值对 key必须可被hash,且必须为不可变数据类型,必须唯一 可存放任意多个值,可修改,可以不唯一 无序 查找速度快,因为hash可以把key ...
- pip安装及使用
1.pip下载安装 1.1 pip下载 # wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5= ...
- 聊聊、Java Keytool P12 转 JKS
最近公司合作机构需要更改服务证书,总共给了 3 个文件过来.openapi-cert.p12.openapi-cert.key.openapi-cert.crt. openapi-cert.crt - ...
- Educational Codeforces Round 34 (Rated for Div. 2)
A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input sta ...