mysql学习问题解决

1.字符串转时间格式函数: STR_TO_DATE('2017-10-19 16:47:00', '%Y-%m-%d %H:%i:%s')

oracle的为to_date

2.specified twice问题

遇到这问题:网上查找的解决方法

【错误内容】:Error Code: 1093. Table '表名' is specified twice, both as a target for 'UPDATE' and as a separate source for data

【错产生经过】:update t_test1 set col1= col1_value where val1 in(select val1 from t_test2 group by val1);

【解决办法】:update t_test1 set col1= col1_value where val1 in(select * from (select val1 from t_test2 group by val1) as T);

注意:经测试delete时,也存在这种情况

3.模糊查询测试中 特别测试的符号  % _ [

由于通配符的缘故,导致我们查询特殊字符“%”、“_”、“[”的语句不能正常实现,而把特殊字符用“[ ]”括起便可正常查询

参考:https://www.cnblogs.com/nxld/p/6120049.html

4、MySQL可以使用check约束,但check约束对数据验证没有任何作用

https://www.cnblogs.com/shishibuwan/p/10862404.html

5、Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t_employee`, CONSTRAINT `t_employee_ibfk_1` FOREIGN KEY (`dept_no`) REFERENCES `t_dept` (`dept_no`))

MySQL设置了foreign key关联,造成无法更新或删除数据。可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况

https://www.cnblogs.com/shishibuwan/p/10862159.html

6、Foreign key constraint is incorrectly formed 外键约束格式不正确

https://www.cnblogs.com/shishibuwan/p/10863347.html

原文地址:https://www.cnblogs.com/shishibuwan/p/9764833.html