SQL Oracle 不等于运算符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4089771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle Not Equals Operator
提问by kuriouscoder
There are two not equals operator - !=
and <>
.
有两个不等于运算符 -!=
和<>
。
What's the difference between them? I heard that !=
is more efficient than other for comparing strings. Could anyone give a qualitative comment on this statement.
它们之间有什么区别?我听说!=
比较字符串比其他方法更有效。任何人都可以对这个声明进行定性评论。
回答by Quassnoi
They are the same (as is the third form, ^=
).
它们是相同的(与第三种形式一样,^=
)。
Note, though, that they are still considered different from the point of view of the parser, that is a stored outline defined for a !=
won't match <>
or ^=
.
但是请注意,从解析器的角度来看,它们仍然被认为是不同的,即为!=
不匹配<>
或^=
.
This is unlike PostgreSQL
where the parser treats !=
and <>
yet on parsing stage, so you cannot overload !=
and <>
to be different operators.
这与PostgreSQL
解析器处理!=
并<>
处于解析阶段的情况不同,因此您不能重载!=
并<>
成为不同的运算符。
回答by Justin Cave
There is no functional or performance difference between the two. Use whichever syntax appeals to you.
两者之间没有功能或性能差异。使用您喜欢的任何语法。
It's just like the use of AS and IS when declaring a function or procedure. They are completely interchangeable.
这就像在声明函数或过程时使用 AS 和 IS 一样。它们完全可以互换。
回答by Catfish
They are the same, but i've heard people say that Developers use !=
while BA's use <>
它们是一样的,但我听人们说开发人员使用!=
而 BA 使用<>
回答by Jon Heller
As everybody else has said, there is no difference. (As a sanity check I did some tests, but it was a waste of time, of course they work the same.)
正如其他人所说,没有区别。(作为健全性检查,我做了一些测试,但这是浪费时间,当然它们的工作方式相同。)
But there are actually FOUR types of inequality operators: !=, ^=, <>, and ?=. See this page in the Oracle SQL reference. On the website the fourth operator shows up as ?= but in the PDF it shows as ?=. According to the documentation some of them are unavailable on some platforms. Which really means that ?= almost never works.
但实际上有四种不等式运算符:!=、^=、<> 和 ?=。请参阅Oracle SQL 参考中的此页面。在网站上,第四个运算符显示为 ?=,但在 PDF 中显示为 ?=。根据文档,其中一些在某些平台上不可用。这真的意味着 ?= 几乎从不工作。
Just out of curiosity, I'd really like to know what environment ?= works on.
出于好奇,我真的很想知道什么环境 ?= 工作。
回答by Shrinivas
Developers using a mybatis-like framework will prefer != over <>. Reason being the <> will need to be wrapped in CDATA as it could be interpreted as xml syntax. Easier on the eyes too.
使用类似 mybatis 的框架的开发人员会更喜欢 != 而不是 <>。原因是 <> 需要包装在 CDATA 中,因为它可以解释为 xml 语法。对眼睛也更轻松。
回答by Jhonatan Aguilar
The difference is :
区别在于:
"If you use !=
, it returns sub-second. If you use <>
, it takes 7 seconds to return. Both return the right answer."
“如果你使用!=
,它返回亚秒。如果你使用<>
,它需要7秒返回。两者都返回正确的答案。”
Oracle not equals (!=) SQL operator
Regards
问候