2 回答
TA贡献1853条经验 获得超9个赞
在使用MySQL数据库时,有时会遇到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)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)
MySQL函数不能创建,是未开启功能:
123456789101112131415161718 | mysql> show variables like '%func%' ; +---------------------------------+-------+ | Variable_name | Value | +---------------------------------+-------+ | log_bin_trust_function_creators | OFF | +---------------------------------+-------+ 1 row in set (0.00 sec) mysql> set global log_bin_trust_function_creators=1; Query OK, 0 rows affected (0.00 sec) mysql> show variables like '%func%' ; +---------------------------------+-------+ | Variable_name | Value | +---------------------------------+-------+ | log_bin_trust_function_creators | ON | +---------------------------------+-------+ 1 row in set (0.00 sec)mysql> |
TA贡献1851条经验 获得超4个赞
你那个是 SQL Server 特有的 表值函数。
也就是一个函数, 返回一个结果集合的。
MySQL 好像是不支持表值函数的样子。 (现在最新的版本支持不支持, 你需要去看看 文档了)
你可以尝试修改成 存储过程 返回结果集的处理。
1234567891011121314151617 | DELIMITER // CREATE DEFINER=`root`@`%` PROCEDURE testProc() BEGIN SELECT 'Hello 1' AS A, 'World 1' AS B UNION ALL SELECT 'Hello 2' AS A, 'World 2' AS B; END // DELIMITER ; mysql> call testProc(); + ---------+---------+ | A | B | + ---------+---------+ | Hello 1 | World 1 | | Hello 2 | World 2 | + ---------+---------+ 2 rows in set (0.00 sec) Query OK, 0 rows affected (0.01 sec) |
添加回答
举报