下面是我创建函数的代码:
delimiter $$
drop function if exists rand_num $$
create function rand_num( )
returns int(5)
begin 
 declare i int default 0;
 set i = floor(10+rand()*500);
 return i;
end $$
delimiter ;然后在命令行模式下执行的时候mysql报错,然后错误如下:
ERROR 1418 (HY000): 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)请问这个是怎么回事啊??怎么解决??

解决方案 »

  1.   

    开启了 bin-log, 我们就必须为我们的function指定一个参数。
    set global log_bin_trust_function_creators =1;
    就解决了。
      

  2.   

    delimiter $$
    drop function if exists rand_num $$
    create function rand_num( )
    returns int(5)
    NO SQL 
    begin 
     declare i int default 0;
     set i = floor(10+rand()*500);
     return i;
    end $$
    delimiter ;
      

  3.   

    先读《数据库系统概论(第四版)》 王珊 萨师煊   高等教育出版社 (掌握基础知识和概念) 然后再粗略浏览一遍MYSQL的官方手册。(方便以后查找,避免类似于考试的时候,给你本政治书也不知道答案在第几章,第几页)MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
      

  4.   


    版主你能解释下那个错误是因为什么原因吗?还有你那句 NO SQL 就是通知mysql说我这个函数不需要sql语句是吧?还有就是因为我们这学期学的就是《数据库系统概论(第四版)》 这本书,所以那些基本概念和知识我应该都了解了,手册的话,现在正在看着呢。我想找些数据库设计的案例的书来看看,你有推荐的么?