为什么在SQLite中需要GLOB子句? [英] Why do we need the GLOB clause in SQLite?

查看:81
本文介绍了为什么在SQLite中需要GLOB子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名Android开发人员,最近遇到了SQLite中的GLOB子句.鉴于LIKE已经到位,我不明白为什么我们需要GLOB.

I'm an Android developer and recently came across the GLOB clause in SQLite. I cannot understand why we need GLOB given that LIKE is already in place.

两个子句都有通配符来表示单个和多个字符.唯一的区别是GLOB区分大小写.

Both clauses have wildcards to represent single and multiple characters. The only difference is that GLOB is case sensitive.

但这就是全部吗?是否有任何疑问是LIKE不好或不合适的选择?在任何情况下,我们是否绝对必须使用GLOBE vs LIKE,反之亦然?

But is that all? Are there any queries where LIKE is a bad or inappropriate choice? Are there any cases where we absolutely have to use GLOBE vs LIKE or vice versa?

推荐答案

区分大小写本身很有用,因为它与常规索引一起使用效果更好.

Case sensitivity is useful by itself, because this works better with normal indexes.

此外,GLOB支持字符类:

Additionally, GLOB supports character classes:

地球规则:

Globbing rules:

*匹配任何零个或多个字符的序列.

* Matches any sequence of zero or more characters.

?精确匹配一个字符.

[...]匹配所附字符列表中的一个字符.

[...] Matches one character from the enclosed list of characters.

[^...]匹配不在所附列表中的一个字符.

[^...] Matches one character not in the enclosed list.

在匹配[...][^...]的情况下,可以包含]字符 列表中的[^之后的第一个字符.一种 可以使用-指定字符范围.例子: [a-z]与任何单个小写字母匹配.要匹配-,请 它是列表中的最后一个字符.

With the [...] and [^...] matching, a ] character can be included in the list by making it the first character after [ or ^. A range of characters can be specified using -. Example: [a-z] matches any single lower-case letter. To match a -, make it the last character in the list.

这篇关于为什么在SQLite中需要GLOB子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆