Postgresql - 在chuncks中更新一个巨大的表

时间:2017-10-26 11:56:19

标签: postgresql plsql

我有一张800万行的表。我想按批次更新此表。

流程看起来像这样,(首先更新1000行,然后提交,然后启动u [pdate from 2000(1000 + 1000)。

    DO$$
    DECLARE i integer;
    DECLARE c integer;


    C := 1000;
    D := c+100;
    i := (SELECT max(id) from test); 


    So the update query will look like,


    begin
    if c <=i
    then

    update table test set id=id+1 where id>=C and id <=i
    C=D;

    Else
    end$$

    Loop2
    Loop3

    End$$

有人可以帮我构建此查询吗?

0 个答案:

没有答案