!=(<>) 和 not in 之间的 Oracle 区别

Oracle difference between !=(<>) and not in

今天我听说使用 <> 的查询比使用 not in 的查询需要更多的时间来执行。 我尝试对此进行测试,并采用相同的计划获得了以下时间结果:

select * from test_table where test <> 'test' 0,063 seconds select * from test_table where test not in ('test') 0,073 seconds

那么问题来了,<>not in对于单个条件有什么区别,用什么比较好

无论该列是否被索引,我都希望两个查询都对 table 执行完整扫描,即查询计划基本相同。您注意到的微小时间差异可能无关紧要 - 运行 相同 查询不止一次,您将获得不同的时间。

话虽如此,我会使用 <> 因为它更自然。