小编CSh*_*Atl的帖子

将 JSONB 列连接到 Postgres 中的普通 PK 列

我正在尝试通过 Postgres 中 jsonb 字段上的属性将普通表连接到具有 jsonb 字段的表。例子:

普通表:

create table Res
(
    id uuid default uuid_generate_v4() not null
        constraint res_pkey
            primary key
)
;
Run Code Online (Sandbox Code Playgroud)

带有 jsonb 的表:

create table res_rem_sent
(
    body jsonb not null,
    search tsvector,
    created_at timestamp with time zone default now(),
    id uuid default uuid_generate_v4() not null
        constraint res_rem_sent_pkey
            primary key
);

create index idx_res_rem_sent
    on res_rem_sent (body)
;

create index idx_search_res_rem_sent
    on res_rem_sent (search)
;
Run Code Online (Sandbox Code Playgroud)

body字段可能如下所示:{"resId": <GUID>, ....}

我想将res表连接到id等于给定 GUID id …

postgresql join json postgresql-9.6

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

标签 统计

join ×1

json ×1

postgresql ×1

postgresql-9.6 ×1