PostgreSQL 如何進行「不區分大小寫」查詢

2021-10-08 22:01:35 字數 1579 閱讀 4392

本文翻譯自:postgresql: how to make 「case-insensitive」 query

is there any way to write case-insensitive queries in postgresql, eg i want that following 3 queries return same result.有什麼辦法可以在postgresql中編寫不區分大小寫的查詢,例如,我希望以下3個查詢返回相同的結果。

select id from groups where name='administrator'

select id from groups where name='administrator'

select id from groups where name='administrator'

參考:如何進行-不區分大小寫-查詢

you can also read up on theilikekeyword.您也可以閱讀ilike關鍵字。it can be quite useful at times, albeit it does not conform to the sql standard.儘管它不符合sql標準,但有時可能會非常有用。see here for more information:

請參閱此處以獲取更多資訊: http :

you can useilike.您可以使用ilikeie

select id from groups where name ilike 'administrator'
使用ilike代替like

select id from groups where name ilike 'administrator'
you could also use posix regular expressions, like您還可以使用posix正規表示式,例如

select id from groups where name ~* 'administrator'
select 'asd' ~* 'asd'returnstselect 'asd' ~* 'asd'返回t

using~*can improve greatly on performance, with functionality of instr.使用~*可以通過instr的功能極大地提高效能。

select id from groups where name ~* 'adm'
return rows with name that contains or equals to 'adm'.返回名稱包含or的行等於「 adm」。

如何進行Monkey Test

一 簡介 monkey是android中的乙個命令列工具,可以執行在模擬器裡或實際裝置中。它向系統傳送偽隨機的使用者事件流 如按鍵輸入 觸控螢幕輸入 手勢輸入等 實現對正在開發的應用程式進行壓力測試。monkey包括許多選項,它們大致分為四大類 基本配置選項,如設定嘗試的事件數量 執行約束選項,如設...

如何進行Code Review

code review應該怎麼做 如何高效迅速的進行codereview 下面推薦一些 code review 工具 crucible atlassian 內部 審查工具 gerrit google 開源的 git 審查工具 github 程式設計師應該很熟悉了,上面的 pull request 在...

如何進行CodeReview

規範主要分為風格規範與設計規範兩大類 主要是文字上的規定,看似表面文章,實際上非常重要。具體有如下幾個方面 1 縮排 2 行寬 3 斷行 空白行 4 括號 5 命名 字母 下劃線 大小寫 6 注釋 a 單行注釋 b 多行注釋 c 變數 方法 類 包注釋 牽涉到程式設計 模組之間的關係 設計模式等方方...