Database Case Insensitive Index?

前端 未结 6 1195
无人及你
无人及你 2021-01-12 16:30

I have a query where I am searching against a string:

SELECT county FROM city WHERE UPPER(name) = \'SAN FRANCISCO\';

Now, this works fine,

6条回答
  •  感情败类
    2021-01-12 17:16

    You could add an indexed column holding a numerical hash key of the city name. (With duplicates allowed).

    Then you could do a multi-clause where :

    hash = [compute hash key for 'SAN FRANCISCO']
    
    SELECT county 
    FROM city 
    WHERE cityHash = hash 
      AND UPPER(name) = 'SAN FRANCISCO' ;
    

    Alternatively, go through your db manual and look at the options for creating table indexes. There might be something helpful.

提交回复
热议问题