服务器之家:专注于服务器技术及软件下载分享
分类导航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|数据库技术|

服务器之家 - 数据库 - PostgreSQL - postgresql sql批量更新记录

postgresql sql批量更新记录

2021-10-11 16:22postgresql教程网 PostgreSQL

向postgresql中利用sql批量跟新记录的实现代码。

复制代码 代码如下:


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();

延伸 · 阅读

精彩推荐