小编Nat*_*ate的帖子

文本列比较等于 where 子句但不选择匹配行

我们在查询生产数据库中的表时遇到问题。一个文本列将与我们在 where 子句中过滤的字符串相等,但 postgres 不会选择该行。(我们在 postgres 11.11 上)我们的表设置如下:

(PROD)=> \d names;
                           Table "public.names"
        Column        |            Type             | Collation | Nullable | Default
----------------------+-----------------------------+-----------+----------+---------
 name                 | text                        |           | not null |
 processed_name       | text                        |           | not null |
 name_index           | integer                     |           | not null |
 when_created         | timestamp without time zone |           | not null |
Indexes:
    "names_pkey" PRIMARY KEY, btree (name, processed_name)
    "names_name_index_key" UNIQUE CONSTRAINT, btree (name_index)
    "ix_names_name" btree (name)
    "ix_names_processed_name" btree (processed_name)
Run Code Online (Sandbox Code Playgroud)

当我们处理名称列表时,我们会检查它们是否已经在表中,以防止重复添加和违反主键约束。

然而,在一个名字上,'?????? ????????? ???????',查看名称是否已经存在的查询返回一个空集, …

postgresql string

6
推荐指数
1
解决办法
67
查看次数

标签 统计

postgresql ×1

string ×1