postgresQL foregin密钥插入


with ins as (
insert into upload_file (
uf_name, 
uf_hash, 
uf_width, 
uf_height, 
uf_ext,
uf_mime,
uf_size, 
uf_path, 
uf_type 
)
values %L
returning uf_idx
)
insert into upload_file_formats (
ud_file_formats,
uf_idx
) select v.formats, ins.uf_idx
from (
values %L
) v(formats)

你好,我现在正在用nodejs pg格式模块进行批量插入。有一个伪造的密钥表,所以我用cte插入。我需要加入。我可以从SQL中获取uf_idx并将uf_idx插入到forgein键表中吗?让我知道是否有办法

您必须将ins添加到第二个INSERTSELECTFROM子句中,可能与类似

FROM ins CROSS JOIN (values %L) v(formats)

最新更新