Oracle SQL开发人员使用始终“ true”条件是从子句中删除。 (xxx“ null或xxx”不是零)

发布于 2025-01-30 12:10:32 字数 413 浏览 2 评论 0原文

我今天使用的是Oracle SQL开发人员版本19.2.1.247,并使用图形方式删除了几行。我的意思是,我选择了行,然后按红色X十字以删除所选的行。 它奏效了,一切都很好。排除行。

但是,我看看日志并发现了这一点:

DELETE FROM "DB"."PERSONS" WHERE ROWID = 'AADG' AND ORA_ROWSCN = '5196' and ( "ID" is null or "ID" is not null )

嗯,我不明白最后一个陈述。

"ID" is null or "ID" is not null

在我看来,显然,这永远是真实的。我对知道这个Oracle SQL开发人员添加此内容的原因感到好奇。为什么使用?何时该陈述是不正确的?

I was using today Oracle SQL Developer version 19.2.1.247 and removed couple of rows using the graphical way. I mean, I selected the row and press the red x cross to remove the selected rows.
It worked, all fine. Rows were removed.

However, I took a look to the logs and find out this:

DELETE FROM "DB"."PERSONS" WHERE ROWID = 'AADG' AND ORA_ROWSCN = '5196' and ( "ID" is null or "ID" is not null )

Well, I don't understand the last statement.

"ID" is null or "ID" is not null

To my eyes, apparently, this is always going to be true. I feel curiosity about knowing the reason why this Oracle SQL Developer is adding this. Why is this used? When this statement will not be true?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月依秋水 2025-02-06 12:10:33

可能只是一个异常,但它不会对声明的执行(或性能)产生任何影响。例如,我做到了:

SQL> create table t as select * from scott.emp;

Table created.

然后删除了SQL Dev中的一行,屈服

DELETE FROM "T" WHERE ROWID = 'AAZRaiABAAAA5eLAAL' 
AND ORA_ROWSCN = '16330866545209' 
and ( "EMPNO" is null or "EMPNO" is not null )

,优化器提出了这一点:

------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------
|   0 | DELETE STATEMENT            |      |     1 |    12 |     1   (0)| 00:00:01 |
|   1 |  DELETE                     | T    |       |       |            |          |
|*  2 |   TABLE ACCESS BY USER ROWID| T    |     1 |    12 |     1   (0)| 00:00:01 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("ORA_ROWSCN"=16330866545209)

简单地忽略了冗余谓词。

我的表没有索引或主键,因此看起来只会从表中从表中获取第一列。

Probably just an anomaly, but it wont have any impact on the execution (or performance) of the statement. For example, I did:

SQL> create table t as select * from scott.emp;

Table created.

and then deleted a row in SQL Dev, yielding

DELETE FROM "T" WHERE ROWID = 'AAZRaiABAAAA5eLAAL' 
AND ORA_ROWSCN = '16330866545209' 
and ( "EMPNO" is null or "EMPNO" is not null )

and the optimizer came up with this:

------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------
|   0 | DELETE STATEMENT            |      |     1 |    12 |     1   (0)| 00:00:01 |
|   1 |  DELETE                     | T    |       |       |            |          |
|*  2 |   TABLE ACCESS BY USER ROWID| T    |     1 |    12 |     1   (0)| 00:00:01 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("ORA_ROWSCN"=16330866545209)

The redundant predicates were simply ignored.

My table had no indexes or primary keys, so it would appear the simply takes the first column from the table for this predicate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文