MySQL字符串按分隔符拆分函数str_split

CREATE FUNCTION `str_split`(
  str VARCHAR(255),
  delim VARCHAR(12),
  pos INT
) RETURNS varchar(255) CHARSET latin1
begin
  RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(str, delim, pos),LENGTH(SUBSTRING_INDEX(str,delim, pos -1)) + 1),delim,'');

end


由于这个函数里没有任何SQL语句,会提示:

Error: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)


这里需要修改一个变量值:

set global log_bin_trust_function_creators = ON;

你可能感兴趣的:(数据库,MYSQL基础)