准备:
sql语句为:
create table a1 (a int);
create table a2 (a int);
create table a3 (a int,b int);
create table a4 (a int,b int);
insert into a1 values (0),(1);//(被除数)(除数)
insert into a2 values (0),(0);//
(被除数)(除数)
insert into a3 values (0,0),(1,1);//
(被除数,测试数)(除数,测试数)
insert into a4 values (0,1),0);//
(被除数,测试数)(除数,测试数)
需要知道的:
select 4/0;
ERROR: division by zero
select * from a1 where (4 / a > 2) and (a > 0);//
(4 / a > 2) a有可能为0
返回1;
select * from a1 where (4 / a > 2) and (a > a-1);
ERROR: division by zero
select * from a2 where (4 / a > 2) and (a > 0);
无返回;
select * from a3 where (4 / a > 2) and (b > 0);
返回1;
select * from a4 where (4 / a > 2) and (b > 0);
ERROR: division by zero
当没有and时,执行计划会根据通过语法解析的节点复杂度进行重新排序,而有or的时候,就会按照手写的顺序。
原文地址:https://www.jb51.cc/postgresql/196199.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。