zoukankan      html  css  js  c++  java
  • mysql delimiter的说明

    默认情况下,mysql解释器一遇到分号(;),它就要自动执行。 
    不会等到用户把这些语句全部输入完之后,再执行整段语句。 

    而自定义函数和存储过程的SQL语句有好多行,且语句中包含有分号,
    为了保证整段语句的整体执行,就要使用delimiter,更改mysql的默认结束符。 

    再看一个列子:

    delimiter $$

    use `test`$$

    drop function if exists `queryOnePartnerInviteCodeByCode`$$

    create function `queryOnePartnerInviteCodeByCode`(_code varchar(4000)) returns varchar(4000) charset utf8
    begin
    set _code=TRIM(_code);

    if _code is null or _code='' then
    return null;
    end if ;

    select GROUP_CONCAT(id) into @__userID from lcs_member where del_flag=0 and invite_code=_code;
    if @__userID is null or @__userID='' then
    return null;
    end if ;


    select GROUP_CONCAT(id),GROUP_CONCAT(invite_code) into @__selectTmpID,@_invite_code from lcs_member where del_flag=0 and invite_code!='' and invite_code is not null and belong_to_partner>0 and FIND_IN_SET(belong_to_partner,@__userID)>0;
    if (@__selectTmpID!='' and @__selectTmpID is not null ) then
    return @_invite_code;
    else
    return null;
    end if;

    end$$

    delimiter;

  • 相关阅读:
    阿里巴巴面试题集合
    mysql的面试试题
    taobao面试要点
    properties文件value换行处理方式
    nginx添加需要代理的域名 配置
    spark基本概念
    MySQL半同步Semi-sync原理介绍【图说】
    J_D 仓储所用mysql版本
    mysql数据库的物理文件结构
    判断浏览器
  • 原文地址:https://www.cnblogs.com/qiumingcheng/p/10220079.html
Copyright © 2011-2022 走看看