oracle之loop使用

每500条记录commit;

sqlplus -s $USER/$PWD@DBNAME <<!!
declare
    lcnt number:=0
    begin
    select count(1) into lcnt from tbsutdent where status='1';
    for i in 0..ceil(lcnt/500)+1 loop
        update tbstudent set status='0' where status='1' and rownum<=500;
        commit;

    end loop;

!!

猜你喜欢

转载自blog.csdn.net/codehouse/article/details/78671387