PostgreSQL唯一索引和字符串大小写 [英] PostgreSQL unique indexes and string case
本文介绍了PostgreSQL唯一索引和字符串大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在字段上创建一个PostgreSQL唯一索引,那么默认情况下比较是否不区分大小写?
If I create a PostgreSQL unique index on a field, is the comparison case-insensitive by default?
如果没有,是否可以要求PostgreSQL忽略字符串case
If not, is it possible to ask PostgreSQL to ignore string case?
推荐答案
PostgreSQL区分大小写。要做你想要的创建一个函数索引。所以说
PostgreSQL is case sensitive. To do what you want create a function index. So say
CREATE UNIQUE INDEX test_upper_idx ON mytable (UPPER(myfield));
这样,当您使用 UPPER(myfield)
在您的查询中将使用索引。
That way when you use UPPER(myfield)
in your query the index will be used.
这篇关于PostgreSQL唯一索引和字符串大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文