gpt4 book ai didi

oracle - ('xyz' != 'xyz' ) 和 NOT ('xyz' = 'xyz' ) 有什么区别

转载 作者:行者123 更新时间:2023-12-03 17:00:37 26 4
gpt4 key购买 nike

('xyz' != 'xyz')NOT ('xyz' = 'xyz') 之间有什么区别吗?

虽然我在 Oracle DB 的上下文中询问,但也想知道其他语言的相同情况。

差异主要在于处理速度和所有背景信息。

最佳答案

有什么不同吗?

测试用例:

SQL> SELECT * FROM dual
2 WHERE ('xyz' != 'xyz');

no rows selected

SQL>
SQL> SELECT * FROM dual
2 WHERE NOT ('xyz' = 'xyz');

no rows selected

在上述两个查询中,应用的过滤器是相同的filter(NULL IS NOT NULL)

执行计划:

SQL> EXPLAIN PLAN FOR
2 SELECT * FROM dual
3 WHERE ('xyz' != 'xyz');

Explained.

SQL>
SQL> SELECT * FROM TABLE(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 3752461848

---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 | 0 (0)| |
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
---------------------------------------------------------------------------

Predicate Information (identified by operation id):

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
---------------------------------------------------

1 - filter(NULL IS NOT NULL)

14 rows selected.

SQL>
SQL> EXPLAIN PLAN FOR
2 SELECT * FROM dual
3 WHERE NOT ('xyz' = 'xyz');

Explained.

SQL>
SQL> SELECT * FROM TABLE(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 3752461848

---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 | 0 (0)| |
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
---------------------------------------------------------------------------

Predicate Information (identified by operation id):

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
---------------------------------------------------

1 - filter(NULL IS NOT NULL)

14 rows selected.

SQL>

没有区别。

关于oracle - ('xyz' != 'xyz' ) 和 NOT ('xyz' = 'xyz' ) 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28828457/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com