是“charlist”吗?样式通配符是 SQL-92 标准的一部分吗?

发布于 2024-09-29 06:02:12 字数 615 浏览 7 评论 0原文

SQL 通配符“%”和“_”已有详细记录并广为人知。然而,正如 w3schools 所解释的,还有“charlist”样式的通配符用于匹配其中的单个字符或在给定范围之外,例如要查找所有名为 Carl 的人,但不查找名为 Earl 的人:

select * from Person where FirstName like '[A-D]arl'

... 或查找相反的人,请使用:

select * from Person where FirstName like '[!A-D]arl'

或 (大概取决于 RDBMS):

select * from Person where FirstName like '[^A-D]arl'

这种类型的通配符是SQL-92 标准,哪些数据库真正支持它?例如:

  • Oracle 11g 不支持
  • SQL Server 2005 支持,否定运算符为“^”(不是“!”)

The SQL wildcards "%" and "_" are well documented and widely known. However as w3schools explains, there are also "charlist" style wildcards for matching a single character within or outside a given range, for example to find all the people called Carl but not those called Earl:

select * from Person where FirstName like '[A-D]arl'

... or to find the opposite, use either:

select * from Person where FirstName like '[!A-D]arl'

or (depending on the RDBMS, presumably):

select * from Person where FirstName like '[^A-D]arl'

Is this type of wildcard part of the SQL-92 standard, and what databases actually support it? For example:

  • Oracle 11g doesn't support it
  • SQL Server 2005 supports it, with the negation operator being "^" (not "!")

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

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

发布评论

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

评论(2

━╋う一瞬間旳綻放 2024-10-06 06:02:12

SQL-99 标准有一个SIMILAR TO 谓词,它使用“charlist”样式以及“%”和“_”通配符。

不过,SQL-92 标准中没有类似的内容(没有双关语)。

The SQL-99 Standard has a SIMILAR TO predicate which uses "charlist" style as well as the "%" and "_" wildcard characters.

Nothing similar (no pun intended) in the SQL-92 Standard, though.

灼痛 2024-10-06 06:02:12

“charlist”运算符看起来像正则表达式,或者它们的有限子集。 AFAIK SQL-92 中没有指定正则表达式语法,尽管许多数据库支持正则表达式,并且它们支持的方式各不相同。例如,Oracle 具有进行正则表达式比较和替换的函数。不知道别人是怎么做到的。

分享并享受。

The "charlist" operators look like regular expressions, or a limited subset of them. AFAIK there's no regular expression syntax specified in SQL-92 although many databases support regex's, and HOW they support it varies. Oracle, for example, has functions to do regular expression comparisons and substitutions. Don't know how others do it.

Share and enjoy.

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