postgresql sql批量更新记录
(编辑:jimmy 日期: 2024/12/22 浏览:3 次 )
复制代码 代码如下:
CREATE FUNCTION updateTchrNm() RETURNS void AS
$body$
DECLARE
rownum integer := 1;
BEGIN
while rownum <= 1000 LOOP
update t_tchr set tchr_nm = '田中愛子' || rownum, tchr_knm = 'タナカアイコ' || rownum, tchr_anm = 'tanaka' || rownum where tchr_cd = 'TCHR' || (1000000 + rownum);
rownum := rownum + 1;
END LOOP;
return;
END;
$body$ LANGUAGE 'plpgsql';
select updateTchrNm();
CREATE FUNCTION updateTchrNm() RETURNS void AS
$body$
DECLARE
rownum integer := 1;
BEGIN
while rownum <= 1000 LOOP
update t_tchr set tchr_nm = '田中愛子' || rownum, tchr_knm = 'タナカアイコ' || rownum, tchr_anm = 'tanaka' || rownum where tchr_cd = 'TCHR' || (1000000 + rownum);
rownum := rownum + 1;
END LOOP;
return;
END;
$body$ LANGUAGE 'plpgsql';
select updateTchrNm();
下一篇:sql 插入数据的三种常用方法及小贴士