goldenDB创建函数索引报错问题
goldenDB创建函数索引时,报错:
ERROR 3761 (HY000): The used storage engine cannot index the expression 'substr(_utf8mb4'CREATE_TIME',0,10)'
解决方案:
1、参数错误
Oracle中substr函数,起始位置参数是0或1时,均视为从字符串的第一个字符开始截取。
在MySQL、goldenDB中,起始位置参数是0时,会返回空;
在MySQL、goldenDB中,创建substr(字段名,0,10)的函数索引,会报错;
正确语法应该是将起始位置参数改为0,,即substr(字段名,1,10)。
2、语法区别
goldenDB中创建函数索引与Oracle相比,语法上略有区别:
Oracle:
create index idx_name on table_name(substr(create_time,1,10));
goldenDB
create index idx_name on table_name((substr(create_time,1,10)));
对比可以发现,goldenDB在语法上,多了个括号。