Why do we need the GLOB clause in SQLite?

半城伤御伤魂 提交于 2019-12-19 05:35:12

问题


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.

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

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?


回答1:


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

Additionally, GLOB supports character classes:

Globbing rules:

* Matches any sequence of zero or more characters.

? Matches exactly one character.

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

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

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.



来源:https://stackoverflow.com/questions/24280980/why-do-we-need-the-glob-clause-in-sqlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!