Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need the GLOB clause in SQLite?

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?

like image 592
kouretinho Avatar asked Jun 18 '14 08:06

kouretinho


People also ask

What is the difference between like clause and glob clause in SQLite?

The GLOB operator is similar to the LIKE operator. The GLOB operator determines whether a string matches a specific pattern. Unlike the LIKE operator, the GLOB operator is case sensitive and uses the UNIX wildcards. In addition, the GLOB patterns do not have escape characters.

How do you use Glob in SQLite?

SQLite GLOB Clause (Operator) The SQLite GLOB operator matches only text values against a pattern by using wildcards. When the search expression is matched with the pattern expression, the GLOB operator will return true which is 1. The GLOB operator follows syntax of UNIX for specifying THE following wildcards.

What is the difference between Glob and like operator in SQL?

If the search expression can be matched to the pattern expression, the GLOB operator will return true, which is 1. Unlike LIKE operator, GLOB is case sensitive and it follows syntax of UNIX for specifying THE following wildcards. The question mark (?) The asterisk sign (*) represents zero or multiple numbers or characters.

What is the difference between Glob and like in Unix?

The GLOB operator is similar to LIKE but uses the Unix file globbing syntax for its wildcards. Also, GLOB is case sensitive, unlike LIKE. And that's it.


1 Answers

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.

like image 155
CL. Avatar answered Oct 05 '22 23:10

CL.