我想更新sqlite表,以下是更新一行的示例:
update tpecroad set tnode = (SELECT b.nodeid FROM "TPECRoad" as a
join tpecnode as b
where pointn(a.geometry,numpoints(a.geometry)) = b.geometry and a.pk =1)
where pk=1
但有168432行需要更新,有没有更快的方法来更新大量数据?
就像改变了a.pk = 1~168432和pk = 1~168432
非常感谢!!
答案 0 :(得分:0)
update tpecroad as c
set tnode = ( SELECT b.nodeid
FROM "TPECRoad" as a join tpecnode as b
where pointn(a.geometry,numpoints(a.geometry)) = b.geometry and a.pk = c.pk);
答案 1 :(得分:0)
试试这个:
Update tpecroad a
set tnode = (SELECT b.nodeid
FROM tpecnode as b
where pointn(tpecroad.geometry,numpoints(tpecroad.geometry)) = b.geometry)
答案 2 :(得分:0)
如果我理解正确的问题,这个查询可能会有所帮助:
update tpecroad a set tnode = (
select b.nodeid from tpecnode b
where pointn(a.geometry,numpoints(a.geometry)) = b.geometry
)
where exists (
select 1 from tpecnode b
where pointn(a.geometry,numpoints(a.geometry)) = b.geometry
);
编辑:如果a.pk = b.pk必须验证执行更新,查询将如下所示:
update tpecroad a set tnode = (
select b.nodeid from tpecnode b
where pointn(a.geometry,numpoints(a.geometry)) = b.geometry
and a.pk = b.pk
)
where exists (
select 1 from tpecnode b
where pointn(a.geometry,numpoints(a.geometry)) = b.geometry
and a.pk = b.pk
);